Skip to content

Signing in by email

The family web app has two links it sends by email, since October 21, 2026:

  • A sign-in link, from Email me a sign-in link under the sign-in form. Opening it signs a Loved One in without a password.
  • A reset link, from Forgot your password?. Opening it leads to Choose a new password, and saving one signs them in.

Before this, a forgotten password was reset by hand (Adding a person). The family's steps are S1 and S6 in the scenarios.

This is not the sign-in link, the standing link for AccessLint's one test account. That one never changes and needs no email.

Accessible Authentication (WCAG 2.2, 3.3.8)

Success Criterion 3.3.8, level AA, says no step of signing in may require a cognitive function test, such as remembering a password or transcribing a code, unless the step offers another way that does not, or a mechanism to help. How the web app meets it:

Step What it asks Why it passes
Sign in with password Remembering a password Alternative: the sign-in link, beside it. Mechanism: the fields are named email and current-password for autofill, and paste is never blocked.
Ask for a link The email address An email address is not a cognitive function test, and the field takes autofill and paste.
Open the link Tapping a button in an email Nothing to remember or copy: the Understanding page names an emailed link as a way that passes. There is no code to type from one device into another.
Sign in from the link One tap on Sign in The page names the account; nothing is typed.
Choose a new password A new password, typed once Creating a password is not recalling one. The field is new-password, so a password manager can make and keep it, under the email shown (username).

Beyond the minimum:

  • Show password, on both password fields, so what was typed can be checked by eye. The new password is asked for once, not twice.
  • No rules but a length: at least 8 characters (MIN_PASSWORD_LENGTH in packages/shared/src/api-types.ts), no required mix of letters and symbols.
  • An hour for a link, long enough to find the email, open it on another device, or come back to it. A link works on any browser, not only the one that asked for it, since many people read email on a phone.
  • Plain words in the email, with the link as a button and again as an address, in plain text and HTML, and one note on what to do if it was not asked for.

How it works

  1. The sign-in form sends POST /auth/email-link with the email typed and a purpose, sign-in or reset (apps/api/src/routes/auth.ts). The answer is 202 and the same words for every address, so it never tells who has an account. The email goes out after the answer (waitUntil), so the time taken does not tell either.
  2. For a Loved One with that email, the Worker stores the SHA-256 of a new 32-byte token in email_tokens (migration 0022) and emails the link through Resend (apps/api/src/resend.ts). The words are in apps/api/src/email-links.ts. An account gets at most 3 emails in 15 minutes; past that, nothing is sent and the answer is the same.
  3. The link is https://silver.equalentry.com/#email-link=<token> (WEB_APP_URL). The token is in the fragment, which the browser never sends to a server. The web app takes it out of the address bar before anything renders (takeEmailLink, apps/web/src/sign-in-link.ts).
  4. The web app asks POST /auth/email-link/check what the link is for, which uses nothing up, and shows one card (apps/web/src/email-link-page.tsx):
  5. Sign in, naming the account. One tap sends POST /auth/email-link/sign-in, which spends the link and starts an ordinary 30-day session. The tap is there because some mail services open every link in an email to check it; a link that signed in on opening would be used up before the Loved One got to it.
  6. Choose a new password. Saving sends POST /auth/reset-password, which checks the length before spending the link, sets the password, ends every other session of the account, stops its other links, and starts a new session.
  7. A link that is unknown, used, or past its hour gets one message: "That link has expired or was already used. A link works once, within an hour. Ask for a new one." The web app shows it above the sign-in form.

What the sign-in form says when no link goes out (apps/web/src/login-form.tsx):

What happened Said where Words
No email typed Under the Email field "Type your email address, then ask for the link."
No @ in it Under the Email field "That does not look like an email address. It needs an @, like name@example.com."
The Worker refuses the address (400) Under the Email field The Worker's words, "Type the email address you sign in with."
Email is not set up (503) Under the two buttons "Email is not working right now, so no link was sent. Sign in with your password, or try again later."
The Worker cannot be reached Under the two buttons "Could not reach the server, so no email was sent. Check your internet connection and try again."

A message under the field marks it aria-invalid, describes it, and takes focus there; every message is role="alert", so a screen reader says it at once. The 503 comes before any account is looked up, so it is the same for every address. What still says "Check your email" with nothing sent: an address with no account, and the fourth request in 15 minutes, both so the form never tells who has an account; and a send Resend refuses, which runs after the answer and is only in the Worker's log.

Seniors have no email and no password, so neither link reaches a senior's account. A superadmin can use both, as with a password.

The sign-in form

Two steps, since October 22, 2026 (apps/web/src/login-form.tsx):

  1. Email alone, and Continue. Nothing is sent to the Worker yet; an empty address or one with no @ is said under the field.
  2. The email again, read-only, with Use a different email; then Password and Sign in, which has focus; then Email me a sign-in link and Forgot your password?.

The email is typed once, whichever way in is chosen, so the link buttons never ask for it again (WCAG 2.2, 3.3.7 Redundant Entry). Both steps name the field username for autofill, and the second keeps it in the form with the password, so a password manager fills both and files a new password under the right account. Before, one form had Email and Password together, with the link buttons under them using the email typed above.

The journey

The link leaves the web app for a mail app and comes back, usually in a new tab. What crosses each step, and what keeps it:

Step Where What happens What crosses, and what keeps it
1 Sign-in form, tab A Types the email, taps Continue, then Email me a sign-in link or Forgot your password? The email, sent to the Worker. Tab A notes the time it asked (localStorage, noteEmailLinkAsked).
2 Check your email, tab A Leaves for the mail app Tab A keeps its place (?tab=...) and its drafts (sessionStorage, tab A's own).
3 The mail app Taps the email's button The token, in the address's fragment.
4 The link's page, tab B Taps Sign in, or saves a new password The session, saved in localStorage, which every tab of the browser shares.
5 Signed in, tab B "The page where you asked for the link is signed in too, with anything you had typed." Said only when this browser asked within the hour (takeEmailLinkAsked).
6 Signed in, tab A "You signed in on another tab, so this one is signed in too. What you had typed here is back." Tab A hears the session arrive (a storage event) and signs in, its place and drafts as they were.

Step 6 is why the journey works for work left unsaved when a session ends ("What you had not saved is kept in this browser"): drafts live in the tab that typed them, and the link opens another. A signed-in tab ignores the event. Opened on another device, the link signs in there, and tab A stays signed out; the Check your email card says to open it on this device to come back to what was typed.

Set it up in production

The Worker sends through Resend, the service equalentry.com's contact form already uses (functions/api/contact.ts in the equalentry.com repo), from Silver <noreply@equalentry.com> (EMAIL_FROM in apps/api/wrangler.jsonc). equalentry.com is already verified in Resend, so there is no DNS to change.

Why Resend rather than Cloudflare Email Sending (tried first, October 21, 2026): Email Sending reaches arbitrary addresses only on Workers Paid, $5 a month. Resend's free tier, 3,000 emails a month and 100 a day, is shared with the contact form and covers both many times over.

  1. In the Resend dashboard, make a new API key for this Worker: name it senior-health-api, with Sending access for equalentry.com only. A key of its own means revoking one never stops the other's email.
  2. Store it in the Worker. This asks for the key; paste it at the prompt, never in a chat or a file:
cd ~/Documents/GitHub/SilverApp/apps/api && npx wrangler secret put RESEND_API_KEY --env production
  1. Deploy, migration first:
cd ~/Documents/GitHub/SilverApp && pnpm --filter @senior-health/api migrate:remote
cd ~/Documents/GitHub/SilverApp && pnpm deploy:api
cd ~/Documents/GitHub/SilverApp && pnpm deploy:web
  1. On https://silver.equalentry.com/, type your own email and tap Email me a sign-in link. The email should come from "Silver".

When an email does not arrive, cd ~/Documents/GitHub/SilverApp/apps/api && npx wrangler tail --env production shows "Email links: sending failed" with Resend's own explanation, such as "The domain is not verified" or "API key is invalid". Before the secret is stored, the form itself says email is not working, and the log says "RESEND_API_KEY or EMAIL_FROM is not set". Resend's dashboard lists every email sent, delivered, or bounced.

Locally

Local development has no RESEND_API_KEY, so nothing is sent: the dev server's log prints the link instead ("Email link (reset) for loved.one@example.com: http://localhost:5173/#email-link=..."). Open it with pnpm dev:web running. The local database needs migration 0022 (pnpm --filter @senior-health/api migrate).

Tests

  • apps/api/tests/routes/email-link-routes.test.ts: the four routes against the real schema, with Resend's address answered in the test: the same answer for an unknown email, the limit, one use, the hour, purpose kept apart, the length checked before the link is spent, other sessions ended.
  • apps/api/tests/email-links.test.ts: the email's words and escaping.
  • apps/api/tests/resend.test.ts: what is posted to Resend, and each way it can refuse.
  • apps/web/tests/email-links.test.tsx: the link's page, and the whole journey of a forgotten password from the sign-in form to signed in, with each write counted.
  • apps/web/tests/login-form.test.tsx and sign-in-link.test.ts: the buttons on the form, their error messages, reading the token out of the address, and the note of when a link was asked for.
  • e2e/tests/test_email_link_journey.py: the journey above in a real browser, with two real tabs: a session ends mid-reminder in tab A, tab A asks for a link, tab B opens it and signs in, and tab A comes back with the reminder and saves it once.

A real email reached a real inbox on October 22, 2026, in Gmail's Updates tab. Not yet tried: the pages with a screen reader, and the two-tab return on a phone, where the mail app may open the link in its own browser rather than a tab of Safari.