Skip to content
Orvanov0.2.0

Email and password

Email and password is the flow every quickstart builds. This page collects the calls in one place, with what each one does to the session. The Next.js, Flutter, and JavaScript quickstarts show them in a finished app.

account.create creates the user and signs them in. The SDK stores the new session.

const { user, isNewUser } = await orvano.account.create({ email, password, name })
  • The email must be unused in the project, ignoring case; a taken one gets user_already_exists.
  • The password needs 8 to 256 characters, or the call gets invalid_password.
  • name is optional.
  • To send a verification email in the same call, pass verificationRedirectUrl; see Email verification.

account.createPasswordSession signs an existing user in. Each sign in opens a new session, so a user can be signed in on many devices at once.

const { user } = await orvano.account.createPasswordSession({ email, password })

A wrong email and a wrong password get the same invalid_credentials, so nobody can find out which emails have accounts. A blocked user with the right password gets user_blocked. After 10 tries in 15 minutes for one email, Orvano answers rate_limited with the seconds to wait.

account.deleteCurrentSession ends this session on Orvano and forgets it on the device. The user’s other sessions stay.

await orvano.account.deleteCurrentSession()

account.updatePassword needs the current password, and ends every other session of the user. This session stays signed in.

await orvano.account.updatePassword({ currentPassword, newPassword })

A user who signed up without a password (with a magic link or an emailed code) can set one without currentPassword, but only within 10 minutes of signing in; after that the call gets reauthentication_required. For a forgotten password, see Password reset.

account.delete deletes the user and every session, for good. It asks for the password the same way:

await orvano.account.delete({ password })

account.get answers with the user, or throws a 401 when nobody is signed in. Each quickstart wraps it in a currentUser helper that answers null instead. account.update changes the user’s name and metadata.