Support both email and phone login

Auto-detect whether the user entered an email or phone number.
Email sends via Resend, phone sends via Twilio SMS. Users table
has nullable phone and email columns; verification_codes uses a
generic identifier field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 08:53:29 -04:00
parent 471cc3ad8c
commit a0c4b28d1e
7 changed files with 177 additions and 56 deletions
+7 -6
View File
@@ -7,24 +7,25 @@
<div class="event-tag">Account</div>
<h1 class="event-title">Log in</h1>
<p style="font-family:'DM Mono',monospace;font-size:0.8rem;color:#555;margin-top:8px;">
Enter your phone number to receive a login code.
Enter your email or phone number to receive a login code.
</p>
</div>
<div class="claim-form-wrapper">
{{if eq .Step "phone"}}
{{if eq .Step "identify"}}
<form method="POST" action="/login">
<div class="form-row">
<label>Phone</label>
<input type="tel" name="phone" placeholder="(555) 123-4567" required autofocus>
<label>Email or phone</label>
<input type="text" name="identifier" placeholder="you@example.com or (555) 123-4567" required autofocus>
</div>
<button class="btn-submit" type="submit">Send code &#8599;</button>
</form>
{{else}}
<form method="POST" action="/login/verify">
<input type="hidden" name="phone" value="{{.Phone}}">
<input type="hidden" name="identifier" value="{{.Identifier}}">
<input type="hidden" name="method" value="{{.Method}}">
<p style="font-family:'DM Mono',monospace;font-size:0.78rem;color:#555;margin-bottom:16px;">
Code sent to <strong>{{.Phone}}</strong>
Code sent to <strong>{{.Identifier}}</strong>
</p>
{{if .Error}}
<p style="color:#c44;font-size:0.85rem;margin-bottom:12px;">{{.Error}}</p>