• Blog
  • Documentation
  • Pricing
  • Help Center
  • Create an Account
  • Log in
Docs Menu
  • Intro
    • What, Why, and How
    • Feature Overview
    • Using the Console
    • Using the Command-line
    • API Clients
    • Custom Domains
    • Environments
  • Deploy
    • Getting Started
    • Configuring Deployments
    • Continuous Deployment
    • Deploying Node.js
    • Deploying Ruby
    • Deploying Java
    • Deploying Liferay DXP
    • Deploying Docker
  • Auth
    • Getting Started
    • Manage Users
    • Sign-in With Password
    • Sign-in With Facebook
    • Sign-in With Google
    • Sign-in With GitHub
    • Environment Variables
  • Data
    • Getting Started
    • Configuring Data
    • Saving Data
    • Getting Data
    • Realtime Data
    • Searching Data
    • Filtering Data
    • Updating Data
    • Deleting Data
    • Environment Variables
  • Email
    • Getting Started
    • Sending Email
    • Checking Status
    • Environment Variables
  • Hosting
    • Getting Started
    • Custom Error Pages
    • Environment Variables

Auth Guide

Manage Users

Create, delete or update users by using WeDeploy Auth.

If you are unfamiliar with our API, please visit the API Clients page first to learn how to install and configure it.

Create user

You create a new user in your WeDeploy project by calling the createUser method or by signing in a user for the first time using an identity provider such as Google or Facebook.

WeDeploy
  .auth('https://-.wedeploy.io')
  .createUser({
    email: 'user@domain.com',
    password: 'abc'
  })
  .then(function(user) {
    // Successfully created.
  })
  .catch(function(err) {
    // Not created.
  });
WeDeploy
  .auth('https://-.wedeploy.io')
  .createUser(email: "user@domain.com", password: "abc", name: "somename")
  .then { user -> Void in
    // Successfully created.
  }
  .catch { err in
    // Not created.
  }
WeDeploy
  .auth("")
  .createUser("user@domain.com", "password", "somename")
  .execute();
curl -X "POST" "https://-.wedeploy.io/users" \
     -H 'Content-Type: application/json' \
     -d '{
       "email": "user@domain.com",
       "password": "abc"
     }'

Get current user

var currentUser = WeDeploy.auth('https://-.wedeploy.io').currentUser;

if (currentUser) {
  // User is signed in.
} else {
  // No user is signed in.
}
WeDeploy
  .auth('https://-.wedeploy.io')
  .getCurrentUser()
  .then { user -> Void in
    // User found.
  }
  .catch { error in
    // User does not exist.
  }
WeDeploy
  .auth("")
  .getCurrentUser()
  .execute();
curl -X "GET" "https://-.wedeploy.io/user" \
     -H 'Authorization: Bearer '

Get user

WeDeploy
  .auth('https://-.wedeploy.io')
  .getUser(userId)
  .then(function(user) {
    // User found.
  })
  .catch(function(err) {
    // User does not exist.
  });
WeDeploy
  .auth('https://-.wedeploy.io')
  .getUser(id: "userId")
  .then { user -> Void in
    // User found.
  }
  .catch { error in
    // User does not exist.
  }
WeDeploy
  .auth("")
  .getUser("userId")
  .execute();
curl -X "GET" "https://-.wedeploy.io/users/" \
     -H 'Authorization: Bearer '

Get all users

WeDeploy
  .auth('https://-.wedeploy.io')
  .getAllUsers()
  .then(function(res) {
    // res contains an array of users.
  })
  .catch(function(err) {
    // An error happened.
  });
WeDeploy
  .auth("https://-.wedeploy.io")
  .getAllUsers()
  .then { res -> Void in
    // res contains an array of users.
  }
  .catch { error in
    // An error happened.
  }
WeDeploy
  .auth("https://-.wedeploy.io")
  .getAllUsers()
  .execute();
curl -X "GET" "https://-.wedeploy.io/users" \
     -H 'Authorization: Bearer '

Delete user

There are two ways to delete a user.

Delete currentUser

WeDeploy
  .auth('https://-.wedeploy.io')
  .currentUser
  .deleteUser()
  .then(function() {
    // Successfully deleted.
  })
  .catch(function(err) {
    // Not deleted.
  });

Delete user by id

WeDeploy
  .auth('https://-.wedeploy.io')
  .deleteUser("userId")
  .then(function() {
    // Successfully deleted.
  })
  .catch(function(err) {
    // An error happened.
  });
WeDeploy
  .auth("https://-.wedeploy.io")
  .deleteUser(id: "userId")
  .then { _ -> Void in
    // Successfully deleted.
  }
  .catch { error in
    // An error happened.
  }
WeDeploy
  .auth("https://-.wedeploy.io")
  .deleteUser("userId")
  .execute();
curl -X "DELETE" "https://-.wedeploy.io/users/" \
     -H 'Authorization: Bearer '

Update user

There are two ways to update a user.

Update currentUser

var currentUser = WeDeploy.auth('https://-.wedeploy.io').currentUser;

currentUser
  .updateUser({
    password: "password",
    email: "eleven@hawkinslabs.com",
    name: "Eleven",
    photoUrl: "https://hawkinslabs.com/011/profile.jpg"
  })
  .then(function() {
    // Successfully updated.
  })
  .catch(function(err) {
    // Not updated.
  });

Update user by id

WeDeploy
  .auth('https://-.wedeploy.io')
  .updateUser(userId, {
    password: "password",
    email: "eleven@hawkinslabs.com",
    name: "Eleven",
    photoUrl: "https://hawkinslabs.com/011/profile.jpg"
  })
  .then(function() {
    // Successfully updated.
  })
  .catch(function(err) {
    // Not updated.
  });
WeDeploy
  .auth('https://-.wedeploy.io')
  .updateUser(id: "userId" , email: "eleven@hawkinslabs.com", password: "password", name: "Eleven")
  .then { _ -> Void in
    // Successfully updated
  }
  .catch { err in
    // Not updated.
  }
JSONObject fields = new JSONObject()
  .put("email", "eleven@hawkinslabs.com")
  .put("password", "newPassword")
  .put("name", "Eleven");

WeDeploy
  .auth("")
  .updateUser("userId", fields)
  .execute();
curl -X "PATCH" "https://-.wedeploy.io/users/" \
     -H 'Authorization: Bearer ' \
     -H 'Content-Type: application/json' \
     -d $'{
        "password": "password",
        "email": "eleven@hawkinslab.com",
        "name": "Eleven",
        "photoUrl": "https://hawkinslabs.com/011/profile.jpg"
      }'

Send a password reset email

You can send a password reset email to a user with the sendPasswordResetEmail method. For example:

WeDeploy
  .auth('https://-.wedeploy.io')
  .sendPasswordResetEmail("user@domain.com")
  .then(function() {
    // Email sent.
  })
  .catch(function(err) {
    // An error happened.
  });
WeDeploy
  .auth('https://-.wedeploy.io')
  .sendPasswordReset(email: "user@domain.com")
  .then { _ -> Void in
    // Successfully signed out.
  }
  .catch { err in
    // Not signed out.
  }
WeDeploy
  .auth("")
  .sendPasswordResetEmail("user@domain.com")
  .execute();
curl -X "POST" "https://-.wedeploy.io/user/recover" \
     -H 'Content-Type: application/json' \
     -d $'{
        "email": "user@domain.com"
      }'
Attention

To send password reset emails, you must have an email service with email as the id in the same project.

If you don't want to use email as service id, you can add this environment variable to your auth service:

{
  "id": "auth",
  "image": "wedeploy/auth:2.8.0",
  "env": {
    "WEDEPLOY_AUTH_EMAIL_SERVICE_URL": "myEmailServiceId"
  }
}

Sign-out

WeDeploy
  .auth('https://-.wedeploy.io')
  .signOut()
  .then(function() {
    // User is signed out.
  })
  .catch(function(err) {
    // User was signed out.
  });
WeDeploy
  .auth('https://-.wedeploy.io')
  .signOut()
  .then { _ -> Void in
    // Successfully signed out.
  }
  .catch { err in
    // Not signed out.
  }
WeDeploy
  .auth("")
  .signOut()
  .execute();
curl -X "POST" "https://-.wedeploy.io/oauth/revoke" \
     -H 'Content-Type: application/json' \
     -d $'{
        "token": ""
      }'

Set User Scopes

User scopes allow you to choose what kind of role or access you provide to each user. This could include things like grouping team users or providing admin access to your app. In order to setup user scopes, you must declare a supportScope when creating or updating a user.

Creating user with user roles

WeDeploy
  .auth('https://-.wedeploy.io')
  .auth('your-master-token')
  .createUser({
    email: 'user@domain.com',
    password: 'abc',
    supportedScopes: ["someScope"]
  })
  .then(function(user) {
    // Successfully created.
  })
  .catch(function(err) {
    // Not created.
  });
curl -X "POST" "https://-.wedeploy.io/users" \
     -H 'Authorization: Bearer ' \
     -H 'Content-Type: application/json' \
     -d '{
        "email": "user@domain.com",
        "password": "abc",
        "supportedScopes: ["someScope"]
      }'

Updating user with user roles

WeDeploy
  .auth('https://-.wedeploy.io')
  .auth('your-master-token')
  .updateUser(userId, {
    password: "password",
    email: "eleven@hawkinslabs.com",
    name: "Eleven",
    supportedScopes: ["friends", "dont", "lie"]
  })
  .then(function() {
    // Successfully updated.
  })
  .catch(function(err) {
    // Not updated.
  });
curl -X "PATCH" "https://-.wedeploy.io/users/" \
     -H 'Authorization: Bearer ' \
     -H 'Content-Type: application/json' \
     -d $'{
        "password": "password",
        "email": "eleven@hawkinslab.com",
        "name": "Eleven",
        "photoUrl": "https://hawkinslabs.com/011/profile.jpg",
        "supportedScopes": ["friends", "dont", "lie"]
      }'
Attention

When setting more than one value to the list of supportedScopes, it works as an AND logical operator.

What's next?

Learn how to sign-in users using their email and password.

Was this section helpful?

Contribute on Github! Edit this section.

Couldn't find what you want?

Don't worry, we're constantly working on improvements. Stay tuned!