Docs : SDK : forgotPassword
forgotPassword lets you send a temporary password to the user's email address. This API will return a promise that gets resolved once the email with the temporary password has been sent.
userbase.forgotPassword({
username: 'example-username'
}).then((user) => {
// email with temporary password sent
}).catch((e) => console.error(e))
Parameters
-
username [string | Len: 1-100] - The username for the account to send a temporary password to.
Notes
-
Resetting a user's password is possible, but only when the user has provided an email address during signUp or updateUser, and when the user has previously signed in with the rememberMe option set to 'local'. In this case, the user will have the encryption key saved in the browser's local storage, and the user will be able to regain access to the account by getting a temporary password via email. The user must still have access to a previously used device in order to be able to reset the password. Therefore, if you want to allow your users to reset their password, make sure to set rememberMe to 'local' during signUp and signIn, and make sure you require an email address during signUp and updateUser. We still recommend that you inform your users that since their data is end-to-end encrypted, they should take care to store their password in a safe place, such as a password manager. Recovery will not be possible if the user loses access to all previously used devices.
Errors
- ParamsMustBeObject
- ParamsMissing
- UsernameCannotBeBlank
- UsernameMustBeString
- AppIdNotSet
- AppIdNotValid
- UserNotFound
- UserEmailNotFound
- KeyNotFound
- ServiceUnavailable