Skip to content
BuildBase

Set up sign-in links and email codes

Let people sign in without a password, with a link or a 6-digit code sent to their email, and choose which one your app sends.

With sign-in links and email codes, nobody has to make up or remember a password. The person types their email address, and BuildBase emails them either a link to tap or a 6-digit code to type on the sign-in page. New people sign up the same way, with their name and email address. It suits apps people use now and then, where a forgotten password would be the usual way back in anyway. It is on every plan.

Links and codes are one method in the console, Magic link, with a setting for what its email sends:

What the email sendsWhat the person doesPick it when
A linkTaps the link in the email. It signs them in on the device and in the browser where they asked for it.People read email on the same computer or phone they use your app on
A 6-digit codeTypes the code from the email on the sign-in page.People read email on their phone and use your app on a computer
EitherGets a code, with a button to have a link sent instead.You are not sure, or your users do both

Before you start

  • An email sender, under Messaging, Sender accounts. Every link and code is an email, and without a sender nothing is sent. See The email sender below.
  • An app (client) with a redirect URL. See Set up sign-in, step by step.

Step by step

  1. In the console's left rail, choose Users, then Authentication under Access, and open the Methods tab.
  2. Press Add auth method and choose Magic link. It is picked already when the dialog opens.
  3. Keep the Title Magic link, or type your own. Your users never see it.
  4. Under What the email sends, choose A link, A 6-digit code or Either.
  5. Press Create.

The Magic link form in the Add new method dialog, with Title "Magic link", the three choices under What the email sends (A link, A 6-digit code and Either, each with one line on when it suits) and the Create button marked 3, 4 and 5; below the choices, a note that it is sent from your email sender under Sender accounts in Messaging, and the Require the same browser switch, on

The ? beside What the email sends gives the rules for each:

The note behind the marked "?" beside What the email sends: a sign-in link works once and lasts one hour and opens on the device where the email is tapped; a code is typed on the sign-in page, is 6 digits, works once, lasts 10 minutes and allows 5 tries, and a new one can be sent after 30 seconds and replaces the last; new users sign up the same way; the email comes from your email sender

RuleLinkCode
How long it works1 hour10 minutes
How many timesOnceOnce, with 5 tries to type it right
Asking for anotherAsk again on the sign-in pageResend code after 30 seconds. The new code replaces the last one
Where it worksOnly in the browser where it was asked forAnywhere the sign-in page is open
How many an hour5 links to one address5 codes to one address

To change what the email sends later, press the pencil (Edit this login method) beside Magic link on the Methods tab, choose again, and press Save. The sign-in page follows at once.

The Edit auth method dialog for Magic link with A 6-digit code chosen and marked under What the email sends, and the Save button marked

The email sender

Every sign-in link and code goes out through your organization's default email sender. Open Messaging in the left rail, then Sender accounts under Configuration. The sender marked System default sends your users' sign-in codes, links, password resets and invitations.

Messaging, Sender accounts in the console: the Email senders card says the one marked System default sends your users' sign-in links and codes, password resets and invitations, and lists one sender, Acme mail, with its System default badge marked, an SMTP account sending from Acme at hello@acme.example

Add new sender connects one of four kinds:

KindWhat it is
SMTPYour email provider's mail server, with its host, port, username and password
GoogleA Gmail or Google Workspace address
MailgunAn email delivery service that sends from your own domain, once the domain is verified
Amazon SESAmazon's email service, with its region and SES SMTP credentials (not AWS access keys)

Why it matters:

  • No sender, no sign-in. Without one, asking for a code or a link is refused with "Email sign-in is unavailable for this organization."
  • People trust a name they know. The email comes from the sender's address and name, here Acme <[email protected]>, and its subject names your app. Use an address on your own domain, such as [email protected], not a personal inbox.
  • Mail from a domain that proves it is yours reaches inboxes. Mail that inbox providers cannot check is often put in spam or turned away, and a sign-in email in spam is a person who cannot sign in. For a Mailgun sender, add and verify your domain on the Domains tab of the same page. For SMTP and Google, your email provider says which DNS records prove the domain is yours.
  • A sender can stop working. If a send fails, for example because the password changed, the sender is marked inactive and nothing goes through it until you fix it.

Attach it to your app

A method shows on the sign-in page only once it is ticked on the app.

  1. Open the Settings tab and press Edit beside Acme Analytics.
  2. Under Methods, tick Magic link. Tick Email and password too if your app should offer both.
  3. Press Update.

The Methods list in the Edit auth setting sheet for Acme Analytics, with Magic link ticked and marked 2, beside Email/Password

Check the preview

The Preview on the Branding page draws a sample card with an Email me a link button under the password form, the same for every app. It shows your name, colours and words, but not which of the three choices your method sends. Press Open the live page for Acme Analytics above it to see the real page with the right button.

What people see

With a code

The sign-in page asks for the email address and offers Email me a sign-in code.

The sign-in page, Sign in to Acme, when the method sends a code: an Email box with sam.rivera@acme.example and the Email me a sign-in code button marked

The next screen takes the code. Didn't get the code? says what to check.

The code screen, Check your email: "Enter the 6-digit code we sent to sam.rivera@acme.example", the Sign-in code box marked, Sign in, Resend code with a timer, and "Didn't get the code?" open with what to check: the spam folder, the address, that codes go only to addresses with an account, and to ask for a new code when the timer runs out; each code works for 10 minutes

The email:

The sign-in code email, subject "Your sign-in code for Acme", from Acme at hello@acme.example to Sam Rivera, with an example 6-digit code marked, how long it works, and when and from which browser it was asked for

On a phone, the code box fills the width, so the code can be typed straight from the email app.

The code screen on a phone: the marked Sign-in code box across the full width, so the code can be typed from the email app on the same phone

An address with no account gets the same screen and no email, so nobody can use the page to find out who has an account.

The sign-in page offers Email me a link.

The sign-in page, Sign in to Acme, when the method sends a link: an Email box with sam.rivera@acme.example and the Email me a link button marked

The page then says where the link went, and that it has to be opened in the same browser.

Check your email: "We sent a sign-in link to sam.rivera@acme.example. Open it on this device, in this browser. It works once, for 1 hour.", with Didn't get the email? and Back to sign in

The sign-in link email, subject "Sign in to Acme", from Acme at hello@acme.example: Hi Sam Rivera, use the link below to sign in to Acme, the Sign in link marked, when and from which browser it was asked for, and that the link only works from this email

Tapping the link signs the person in and takes them back to your app.

A link only finishes the sign-in it was asked for, in that browser. Someone who asks for a link on their laptop and taps it on their phone, or opens it in a different browser on the same computer, sees "Could not sign you in with this link" and "For your security, this link signs you in only in the browser where you asked for it", with the way to open it there or go to the app and ask for a new link in this browser. Opening it there still works: looking at it in the wrong browser does not use it up. With Require the same browser off, the line says instead that the link was requested in a different browser.

The link opened in a different browser: "Could not sign you in with this link" and "For your security, this link signs you in only in the browser where you asked for it. Open it there, or go to the app and ask for a new link in this browser."

This keeps a forwarded or intercepted link from signing anyone else in. A link that was already used, or is more than an hour old, says so instead: "This link has expired or was already used. Ask for a new one on the sign-in page." If your users often open links on another device, switch the method to A 6-digit code or Either.

Require the same browser

The Magic link dialog (add or edit) has a switch, Require the same browser, on for every organization unless you turn it off. It applies to every magic link in your organization and saves as soon as you switch it.

  • On: a link signs in only in the browser that asked for it. A link opened anywhere else, by a person, a forwarded email or an email security scanner, cannot sign in, and is not used up: the browser that asked can still finish. The other browser sees "For your security, this link signs you in only in the browser where you asked for it", with the way to open it there or ask for a new link.
  • Off: a link signs in a browser that has started its own sign-in on your page, even if another browser asked for it.

The cost of leaving it on: someone who opens the email on another device has to open the link in the browser they started in, or ask for a new link where they are. A 6-digit code or Either avoids that. Each change is written to the Audit tab as a security settings change.

With either

The sign-in page offers both buttons. The code comes first, and the code screen has Send me a link instead.

The sign-in page when the method sends either: Email me a sign-in code, and under it Email me a link, both marked

The code screen when the method sends either: the same Sign-in code box, with Send me a link instead marked under Resend code

Signing up

When the method sends a code (A 6-digit code or Either) and the app has no password method, Create account asks for a name and an email, then sends a code. The account is made when the code is typed, with the address already confirmed.

Create your Acme account with email codes: Name Sam Rivera and Email sam.rivera@acme.example, the Email me a code button marked, and "We will email you a 6-digit code to confirm the address"

The code screen while signing up: "Enter the 6-digit code we sent to sam.rivera@acme.example to create your account", the Verification code box marked, a Create account button and a Resend code timer

When the method sends only A link, Create account asks for a name and an email, makes the account, and then asks for a 6-digit code from an email to confirm the address, as after a password sign-up. When the app also has Email and password, the sign-up form asks for a password as usual, and the code or link is a second way to sign in later. If you closed public sign-up or set who can sign up, the same rules apply to code sign-ups.

If the person has two-step sign-in on, the code or link is followed by their second step, as after a password.

Check it works

  • Sender accounts has a sender marked System default.
  • The Methods tab lists Magic link, with the choice you want.
  • Magic link is ticked on your app, and Update was pressed.
  • Test beside the app shows Email me a sign-in code, Email me a link, or both.
  • The email arrives from your sender's address, and the code or link signs you in.
  • A link opened in a private window says it signs you in only in the browser where you asked for it (or, with Require the same browser off, that it was requested in a different browser).

Things to watch out for

  • A link signs in only the browser that asked for it. A private window, another browser, or an email app that opens links in its own built-in browser all count as a different browser, and the person sees "For your security, this link signs you in only in the browser where you asked for it." (with Require the same browser off: "This link was requested in a different browser.") If your users read email on a phone and use your app on a computer, choose A 6-digit code or Either.
  • A new code replaces the last one. Someone who pressed Resend code and types the code from the first email is told it did not match. Point them at the newest email.
  • Codes last 10 minutes and links one hour. Someone who comes back to an old email has to ask again.
  • A sign-in email in spam is a person who cannot sign in. Send from your own domain with the DNS records your email provider gives (see The email sender), and turn on bot protection before launch so a script cannot make you send thousands of emails.

If something goes wrong

What the person seesWhyWhat to do
"Email sign-in is unavailable for this organization."No working default email senderConnect one under Messaging, Sender accounts, and mark it System default
No email arrivesThe email is in spam, the address has no account, or the hourly limit was reachedCheck Sender accounts; verify your sending domain; ask them to check spam and the address
"That code did not match. Try the newest code."A wrong code, or an older code after a new one was sentType the newest code
"This code has expired. Ask for a new one."More than 10 minutes passedResend code
"Please wait 20 seconds before asking for another code." (the number counts down)A new code was asked for within 30 seconds of the lastWait for the timer, then Resend code
"Too many codes were requested for this address. Use the latest one, or try again in an hour."More than 5 codes, or 5 links, went to this address within an hourUse the newest email, or wait an hour
"This link was requested in a different browser. Open it in the browser where you asked for it, or go to the app and ask for a new link there."Require the same browser is off, and the link was opened in a browser other than the one that asked for itOpen it in that browser, or ask for a new link
"For your security, this link signs you in only in the browser where you asked for it. Open it there, or go to the app and ask for a new link in this browser."Require the same browser is on (the default) and the link was opened in another browserOpen it in that browser, or ask for a new link
"This link has expired or was already used. Ask for a new one on the sign-in page."The link ran out or was usedAsk for a new link
"Please use a permanent email address."You refuse throwaway addressesSign up with another address
"Sign-up isn't available for this address."Your sign-up rules refuse itAdd the address to the allowlist, or change the mode
"The security check expired or did not pass. Please try it again."Bot protection did not passTry the check again

Next steps