UserStore

Authentication

Basic set of API calls to handle the authentication workflow. This includes sign in, sign out, forgot password, reset password, verify account, and confirm password.

Sign In

Returns the user if credentials are correct.

Arguments

signin_id
required
The user's email address or username.
password
required
The user's password.
Definition
POST https://api.userstore.io/1/auth/signin
userstore.auth.signin(signin_id, password, callback)
Example Request
curl https://api.userstore.io/1/auth/signin \
   -u SECRET_KEY: \
   -d [email protected] \
   -d password="Sz4kF^12cpsk"
userstore.auth.signin(
  '[email protected]',
  'Sz4kF^12cpsk',
  function(err, user) {}
);
                  
Object Response
{
  "id": "lFVofRqhZ",
  "email": "[email protected]",
  "username": "johnsmith",
  "first_name": "John",
  "last_name": "Smith",
  "is_active": true,
  "is_email_verified": true,
  "last_signin": "2014-08-04T23:48:34.288Z",
  "updated_at": "2014-08-04T23:46:19.106Z",
  "created_at": "2014-08-04T23:46:19.106Z"
}
                  

Sign Out

Records that the user has signed out (under their activity in the UserStore Dashboard).

Note: This simply records the user activity in UserStore. Your application should still manage or terminate the user's session in addition to this call.

Arguments

id
required
The user's ID.
Definition
POST https://api.userstore.io/1/auth/signout
userstore.auth.signout(id, callback)
Example Request
curl https://api.userstore.io/1/auth/signout \
   -u SECRET_KEY: \
   -d id=lFVofRqhZ
userstore.auth.signout(
  'lFVofRqhZ',
  function(err, user) {}
);
                  
Object Response
{
  "id": "lFVofRqhZ",
  "email": "[email protected]",
  "username": "johnsmith",
  "first_name": "John",
  "last_name": "Smith",
  "is_active": true,
  "is_email_verified": true,
  "last_signin": "2014-08-04T23:48:34.288Z",
  "updated_at": "2014-08-04T23:46:19.106Z",
  "created_at": "2014-08-04T23:46:19.106Z"
}
                  

Confirm Account

Confirms the user's password. This can be used when you want to confirm the user is present to enter their password for an important action.

Arguments

code
required
The user's ID.
password
required
The user's password.
Definition
POST https://api.userstore.io/1/auth/confirm
userstore.auth.confirm(id, password, callback)
Example Request
curl https://api.userstore.io/1/auth/confirm \
   -u SECRET_KEY: \
   -d id=lFVofRqhZ \
   -d password="Sz4kF^12cpsk"
userstore.auth.confirm(
  'lFVofRqhZ',
  'Sz4kF^12cpsk',
  function(err, response) {}
);
                  
Object Response
{
  "confirmed": true
}
                  

Verify Account

Verify the user's account. The required code can be generated when a user is created or when they change their email address.

Arguments

code
required
The user's verification code.
Definition
POST https://api.userstore.io/1/auth/verify
userstore.auth.verify(id, password, callback)
Example Request
curl https://api.userstore.io/1/auth/verify \
   -u SECRET_KEY: \
   -d code=lFVolFVofRqhZfRlFVofRqhZqhZ
userstore.auth.verify(
  'lFVolFVofRqhZfRlFVofRqhZqhZ',
  function(err, response) {}
);
                  
Object Response
{
  "id": "lFVofRqhZ"
}
                  

Forgot Password

Generate a reset password code with the option to send an email. Make sure your mail settings are properly configured in your app dashboard.

Options

send_email
optional, default is false
Send a forgot password email with a reset password link using mail template and settings configured in your app dashboard.
reset_password_url
required if send_email is true
The absolute URL to the reset password page on your site. A query parameter 'code' will be passed to your page.

Arguments

email
required
The user's email.
Definition
POST https://api.userstore.io/1/auth/forgot-password
userstore.auth.forgotPassword(email, options, callback)
Example Request
curl "https://api.userstore.io/1/auth/forgot-password?send_email=true&reset_password_url=https%3A%2F%2Fexample.com%2Freset-password" \
   -u SECRET_KEY: \
   -d [email protected]
userstore.auth.forgotPassword(
  '[email protected]',
  {
    send_email: true,
    reset_password_url: 'https://example.com/reset-password'
  },
  function(err, response) {}
);
                  
Object Response
{
  "code": "fdd8ed77417641dda3a39fa4ce591417"
}
                  

Reset Password

Reset the user's password.

Arguments

code
required
The reset password code from the forgot password request.
password
required
The user's new password.
Definition
POST https://api.userstore.io/1/auth/reset-password
userstore.auth.resetPassword(code, password, callback)
Example Request
curl https://api.userstore.io/1/auth/reset-password \
   -u SECRET_KEY: \
   -d code=fdd8ed77417641dda3a39fa4ce591417 \
   -d password="Sz4kF^12cpsk"
userstore.auth.resetPassword(
  'fdd8ed77417641dda3a39fa4ce591417',
  'Sz4kF^12cpsk',
  function(err, user) {}
);
                  
Object Response
{
  "updated_at": "2015-09-19T05:30:01.346Z"
}