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, password, rememberMe = 'session' })
.then((user) => {
// user logged in
})
.catch((e) => console.error(e))
Parameters
-
username [string | Len: 1-50] - 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.
- email [string] - The user's email.
- profile [object] - The user's profile.
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 true, the user's encryption key will be stored in clear in the browser's local storage. If you want to avoid this, you will need to set rememberMe to false (the default). When rememberMe is false, the user will always have to login with the username and password when visiting your web app.
Errors
- ParamsMustBeObject
- UsernameOrPasswordMismatch
- UsernameCannotBeBlank
- UsernameTooLong
- UsernameMustBeString
- PasswordCannotBeBlank
- PasswordTooShort
- PasswordTooLong
- PasswordMustBeString
- RememberMeValueNotValid
- AppIdNotSet
- AppIdNotValid
- UserAlreadySignedIn
- ServiceUnavailable