signIn lets your users log into your web app. This API will return a promise that gets resolved once the user has been logged in.
userbase.signIn({
username: 'example-username',
password: 'example-password'
}).then((user) => {
// user logged in
}).catch((e) => console.error(e))
Parameters
-
username [string | Len: 1-100] - The username for the account to be login.
-
password [string | Len: 6-1000] - The password for the account to be login.
-
rememberMe [string | optional] - The persistence mode for the user's session. Valid values are 'local', 'session', and 'none'. When set to 'local', the session persists even after the browser window gets closed. When set to 'session', the session persists until the browser window gets closed. And 'none' disables session persistence completely. Defaults to 'session'.
Result
-
user [object] - Contains information about the logged in user.
- username [string] - The user's username.
- userId [string] - The user's unique identifier.
- email [string] - The user's email.
- profile [object] - The user's profile.
- usedTempPassword [boolean] - Indicates if the user has signed in with a temporary password from the forgotPassword workflow. You may want to prompt the user to change the password when this is true.
Notes
-
The user's password is never sent to the server. A hash gets computed client-side, and only the hash is transmitted and stored server-side.
-
When rememberMe is set to 'session' or 'local', the user's encryption key will be stored in clear in the browser's session or local storage respectively. If you want to avoid this, you will need to set rememberMe to 'none'. When rememberMe is 'none', the user will always have to login with the username and password when visiting your web app.
Errors
- ParamsMustBeObject
- UsernameMissing
- UsernameOrPasswordMismatch
- UsernameCannotBeBlank
- UsernameTooLong
- UsernameMustBeString
- PasswordMissing
- PasswordCannotBeBlank
- PasswordTooShort
- PasswordTooLong
- PasswordMustBeString
- PasswordAttemptLimitExceeded
- RememberMeValueNotValid
- KeyNotFound
- AppIdNotSet
- AppIdNotValid
- UserAlreadySignedIn
- ServiceUnavailable