Auth

View on Github

Auth handles authentication of a single user, such as signing up, logging in & out, social provider authentication, etc.

Properties

passwordResetUrlstring

Link the user to this URL for password resets. Only for email/password authentication.

Use this if you want to use our password reset forms instead of creating your own in your app.

Methods

isAuthenticated(): boolean

Check whether the user is logged in or not.

If an auth token exists in local storage, the user is logged in.

signup(detailsUserDetails): Promise<void>

Sign up a user with the given data. Only for email/password authentication.

signup does not affect local data or the current user until login is called. This means you’ll likely want to log in your users manually after signup.

If a signup fails, the promise rejects with a IDetailedError object that contains an array of error codes from the cloud.

details

The details that describe a user.

login(moduleIdAuthModuleIdcredentials?Objectoptions?AuthLoginOptions): Promise<AuthLoginResult>

Attempt to log the user in with the given credentials. For custom & social logins, kick-off the authentication process.

After login, the full user is loaded from the cloud and saved in local storage along with their auth token.

moduleId

The authentication provider module ID to use with this login.

credentials (optional)

For email/password authentication, give an email and password. For social authentication, exclude this parameter. For custom authentication, send whatever you need.

options (optional)

Options for this login, such as whether to remember the login and InAppBrowser window options for authentication providers that make use of it.

logout(): void

Log the user out of the app.

This clears the auth token out of local storage and restores the user to an unauthenticated state.

requestPasswordReset(emailstring): Promise<void>

Kick-off the password reset process. Only for email/password authentication.

An email will be sent to the user with a short password reset code, which they can copy back into your app and use the confirmPasswordReset() method.

email

The email address to which to send a code.

confirmPasswordReset(codenumbernewPasswordstring): Promise<void>

Confirm a password reset.

When the user gives you their password reset code into your app and their requested changed password, call this method.

code

The password reset code from the user.

newPassword

The requested changed password from the user.

getToken(): string |

Get the raw auth token of the active user from local storage.

Services

    API

      General