signUp lets you create user accounts for your web app. This API will return a promise that gets resolved once the user account has been created.
userbase.signUp({
username: 'example-username',
password: 'example-password'
}).then((user) => {
// user account created
}).catch((e) => console.error(e))
Parameters
-
username [string | Len: 1-100] - The username for the account to be created.
-
password [string | Len: 6-1000] - The password for the account to be created.
-
email [string | optional] - The email for the account to be created.
-
profile [object | optional | Key Len: 1-20 | Val Len: 1-1000 | Keys: 1-100] - A place where to store some information about the account to be created. All keys and values must be strings.
-
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'.
-
sessionLength [number | optional | Unit: hours | Min: 0.084 (5 mins) | Max: 8760 (1 yr) ] - The number of hours the user's session will remain active. Defaults to 24.
Result
-
user [object] - Contains information about the new user.
- username [string] - The user's username.
- userId [string] - The user's unique identifier.
- authToken [string] - The user's authentication token that can be used to verify the user is signed in via the Verify Auth Token endpoint in the Userbase Admin API.
- creationDate [string] - The date the user was created.
- email [string] - The user's email.
- profile [object] - The user's profile.
- paymentsMode [string] - The app's payments mode set in your Admin panel. Can be 'disabled', 'test', or 'prod'.
- trialExpirationDate [string] - The date the user's trial expires.
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.
-
The username, email, and profile are not end-to-end encrypted. They are encrypted in transit and at rest, but you will be able to see this information in the Admin panel.
-
When rememberMe is set to 'session' or 'local', the user's encryption key and session token will be stored in clear in the browser's session or local storage respectively. Someone with access to these values will be able to access a user's account and all their data until the user explicitly signs out, or the user's session expires. 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.
-
When the app's paymentsMode is set to 'test' or 'prod' in the admin panel, and the app's subscription plan has a trial period set in Stripe, the trialExpirationDate is determined based on the trial period and the date the user is created.
Errors
- ParamsMustBeObject
- UsernameMissing
- UsernameAlreadyExists
- UsernameCannotBeBlank
- UsernameMustBeString
- UsernameTooLong
- PasswordMissing
- PasswordCannotBeBlank
- PasswordTooShort
- PasswordTooLong
- PasswordMustBeString
- EmailNotValid
- ProfileMustBeObject
- ProfileCannotBeEmpty
- ProfileHasTooManyKeys
- ProfileKeyMustBeString
- ProfileKeyTooLong
- ProfileValueMustBeString
- ProfileValueCannotBeBlank
- ProfileValueTooLong
- RememberMeValueNotValid
- SessionLengthMustBeNumber
- SessionLengthTooShort
- SessionLengthTooLong
- TrialExceededLimit
- AppIdNotSet
- AppIdNotValid
- UserAlreadySignedIn
- ServiceUnavailable