Skip to content
v2.7

Verification and recovery

Confirm the user's email (by link) and phone (by SMS code) and reset a forgotten password.

The email flows all have the same shape: Owbase sends an email with a link to a page in your app, and that page completes the process with the userId and secret that come in the address. The page’s domain must be in Platforms.

The email texts live in Auth → Emails, in the console. To edit them, first turn on Use custom SMTP (the project’s own email server); without it, emails go out with Owbase’s default text.

verificacao.ts
import { Account } from '@owbase/web';
import { client } from './client';
const account = new Account(client);
// 1. With the user signed in: sends the email with the confirmation link to this page of your app.
await account.createEmailVerification({ url: 'https://app.example.com/confirm' });
// 2. On the /confirm page: the link arrives with ?userId=…&secret=…
const params = new URLSearchParams(window.location.search);
await account.updateEmailVerification({ userId: params.get('userId') ?? '', secret: params.get('secret') ?? '' });

Once confirmed, user.emailVerification becomes true, and the Role.users('verified') role starts applying to that user in permissions.

The account’s phone is confirmed with an SMS code, sent by Openwave, the same way as phone sign-in: the organization must be enabled for SMS and each code sent costs the same (US$ 0.08, counted as usage; Brazilian numbers only, other countries with Openwave’s approval). The user must be signed in and have a phone on the account (for example, someone who signed up by email and later provided a phone with account.updatePhone). Whoever signs in through phone sign-in already has a confirmed phone: requesting verification again returns 409 user_phone_already_verified.

verificacao-telefone.ts
import { Account } from '@owbase/web';
import { client } from './client';
const account = new Account(client);
// 1. With the user signed in (and a phone number on the account): sends the code by SMS to the account's phone.
const token = await account.createPhoneVerification();
// 2. The user types the code they received.
await account.updatePhoneVerification({ userId: token.userId, secret: '123456' });

Once confirmed, user.phoneVerification becomes true. The code is valid for 10 minutes and allows 3 attempts; the errors are the same as for phone sign-in.

recuperacao.ts
import { Account } from '@owbase/web';
import { client } from './client';
const account = new Account(client);
// 1. On the "forgot password" screen: sends the email with the link to this page of your app.
await account.createRecovery({ email: '[email protected]', url: 'https://app.example.com/new-password' });
// 2. On the /new-password page: the link arrives with ?userId=…&secret=…
const params = new URLSearchParams(window.location.search);
await account.updateRecovery({ userId: params.get('userId') ?? '', secret: params.get('secret') ?? '', password: 'another-strong-password' });

The recovery link is valid for a limited time and works only once; if it expires, request another with createRecovery.

Was this page helpful?