Photo Social App with FlutterFlow and Supabase · Course book
Chapter 31: Email Verification
Anyone can type an email address into a sign-up form, including one that belongs to someone else or does not exist at all. Email verification asks new users to prove they own the address, by clicking a link sent to it, before the account becomes fully active. It protects real owners of addresses, keeps password recovery trustworthy and cuts down on fake accounts. This chapter builds verification into the photo app with FlutterFlow and Supabase: how the confirmation flow works, the custom actions involved, the different handling needed on the web and on phones, the Supabase configuration, an extra step for apps that create profile rows at sign-up, and testing. It also designs a fair "resend email" rule, worked out by hand with a graph.
How verification works
When email confirmation is switched on in Supabase, signing up creates the account in an unconfirmed state and sends an email containing a link with a one-time token. Until the link is clicked, the user cannot sign in with that account. Clicking the link confirms the address, and Supabase can then send the user back to the app, signed in, using a redirect address the app provides.
| Stage | Account state | What the app shows |
|---|---|---|
| Just signed up | Created, email unconfirmed | "Check your inbox" page with the address and a resend button |
| Tries to log in before confirming | Unconfirmed; sign-in refused | A clear message and an offer to resend the email |
| Clicks the link | Confirmed | Opens the app, signed in, and continues to onboarding |
| Link expired or already used | Still unconfirmed, or already confirmed | An explanation and a way to request a new link, or to log in |
The prerequisites are the earlier pieces of the series: email authentication set up, ideally with a custom email server so that confirmation emails are delivered reliably, and a deep link scheme for the phone app, as used for password resets.
Custom actions in FlutterFlow
As with password reset, small custom actions written in Dart give precise control over the flow. One signs up with an emailRedirectTo value, telling Supabase where the confirmation link should lead: the deep link for the phone app, or the web address of a confirmation page for the web version. Another resends the confirmation email, for users who did not receive the first one or let it expire. A third, run when the app opens from a link, lets the Supabase client process the token and reports whether the user is now signed in.
The sign-up page then changes slightly. Instead of moving straight to onboarding after creating the account, it navigates to a check your inbox page, which names the address the email was sent to, so users can spot a typo, and offers "Resend email" and "Use a different address" options. Onboarding begins only once the address is confirmed and the user is signed in.
The login page needs a small change too. When someone tries to sign in before confirming, Supabase refuses with an error that says the email has not been confirmed. Rather than showing that raw message, the app can recognise it and respond helpfully: "Please confirm your email first. We sent a link to maya@example.org", with a button to resend it. Treating this as a normal step, not an error, keeps new users from thinking the app is broken. Remembering the address typed at sign-up, for example in app state, means the inbox page and the login message can show it without asking again.
Verification also affects existing accounts. Switching confirmation on in a live app does not retroactively confirm accounts that already exist; depending on the settings, earlier users may already be treated as confirmed, or may be asked to confirm on their next sign-in. Deciding this before switching the setting on, and testing it with an existing test account, avoids locking current users out unexpectedly. Changing an email address later should also send a confirmation to the new address, so that the account never moves to an address its owner does not control.
Web and mobile, and configuring Supabase
The confirmation link behaves differently depending on where it is opened, so both cases need handling.
- On the web, the link opens the site's confirmation page in the browser. The page loads with the token in its address, the Supabase client processes it, and the page can then continue to onboarding or show "Email confirmed, you can now log in".
- On a phone, the link uses the app's deep link scheme, which the operating system routes to the installed app. The app's start-up code passes the link to the Supabase client, which confirms the session, and the app navigates on. If the app is not installed on that device, the link cannot open it, which is why a web fallback is valuable.
Supabase must trust every address the link might use. In the authentication settings, email confirmations are switched on, the site address is set, and the redirect URLs list includes both the deep link and the web confirmation page. The confirmation email template can be edited to carry the app's name, a clear button and a short note that the link expires. Supporting both web and mobile at once simply means listing both redirect addresses and choosing the right one in the sign-up action according to the platform the app is running on.
A fair resend rule
Users often ask for the email again within seconds, before the first has arrived, and an unrestricted resend button could be abused to flood someone's inbox. Supabase applies its own limits, but the app should also make the button sensible: briefly disabled after each send, with a countdown, and waiting longer after repeated requests. A common design doubles the wait each time.
The countdown should be visible on the button itself, "Resend in 45s", so the user knows the wait is deliberate and how long it lasts. Storing the time of the last send in page state, or in app state if the user may leave and return to the page, lets the countdown survive navigation. If the user changes the address instead of resending, the wait can reset, since the new address has not yet received anything.
The extra step for this app, and testing
This app creates a profile row in the users table as part of sign-up, and then sends new users through onboarding. With verification switched on, the sign-up response no longer includes a signed-in session, because the user must confirm first, so an action that inserts the profile row immediately after sign-up may fail its security policy, which requires an authenticated user. Two fixes work. The profile row can be created by a database trigger on new accounts, which runs regardless of sign-in state, or the insert can move to the moment the user first arrives confirmed and signed in, at the start of onboarding. The trigger is the more robust choice, because it guarantees every account has a profile however it was created.
Testing must use real inboxes. Sign up with a new address on a phone, check the inbox page, open the email on the same phone and confirm that the app opens signed in and continues to onboarding. Repeat on the web. Then try the awkward paths: logging in before confirming, resending several times and watching the countdown grow, opening an expired link, opening a link twice, and opening the link on a computer when the account was created on a phone. Each should end with a clear message and an obvious next step, never a dead end or a confusing error.
Practice tasks
- With a wait of 20 seconds that doubles each time and a cap of 320, list the waits for six attempts and their total.
- How many emails could be requested per hour once a 240-second cap is reached?
- Why must the redirect URL list include both the deep link and the web confirmation page?
- Explain why inserting the profile row right after sign-up can fail once confirmation is required, and two ways to fix it.
- What should the check-your-inbox page show, and why does naming the address help?
- Describe what happens when the confirmation link is opened on a device without the app installed.
This course book is available to read online only at tech-academy.chrysolites.org.