Phase 10, part 3: signing in and out, resets, locks and two-factor
The server edition now starts. Sign-in by email and password, limited per address and per IP; ten failures in a row lock the account and email its owner, and a reset by email (or an admin) unlocks it. Settings → Your account has the profile, the password, where you're signed in, and two-factor sign-in with an authenticator app (TOTP, from a QR code) and ten recovery codes. The app's own mail goes through SUPERMARKET_MAIL_URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$d := .}}
|
||||
<h2>Your account</h2>
|
||||
<p class="lede">{{.U.Email}} · {{.Role}}{{if not .U.SignedIn.IsZero}} · signed in {{ago .U.SignedIn}}{{end}}</p>
|
||||
|
||||
<form class="card" method="post" action="/settings/account/profile" id="profile">
|
||||
<h2>About you</h2>
|
||||
{{if eq .Section "profile"}}<p class="error" role="alert">{{.Problem}}</p>{{end}}
|
||||
<div class="cols">
|
||||
<label>Name <input name="name" value="{{.U.Name}}" autocomplete="name" required></label>
|
||||
<label>Title <input name="title" value="{{.U.Title}}" placeholder="e.g. Head of marketing" autocomplete="organization-title"></label>
|
||||
</div>
|
||||
<label>Time zone <input name="time_zone" value="{{.U.TimeZone}}" list="zones" placeholder="e.g. Europe/Paris">
|
||||
<span class="help">Times are shown in it. Empty: the server's.</span></label>
|
||||
<datalist id="zones">{{range .Zones}}<option value="{{.}}">{{end}}</datalist>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
<form class="card" method="post" action="/settings/account/password" id="password">
|
||||
<h2>Password</h2>
|
||||
{{if eq .Section "password"}}<p class="error" role="alert">{{.Problem}}</p>{{end}}
|
||||
<input type="text" name="username" value="{{.U.Email}}" autocomplete="username" hidden>
|
||||
<label>Current password <input type="password" name="current" autocomplete="current-password" required></label>
|
||||
<div class="cols">
|
||||
<label>New password <input type="password" name="password" autocomplete="new-password" minlength="10" required>
|
||||
<span class="help">At least 10 characters.</span></label>
|
||||
<label>The new one again <input type="password" name="password2" autocomplete="new-password" minlength="10" required></label>
|
||||
</div>
|
||||
<p class="help">Changing it signs you out everywhere else.</p>
|
||||
<button type="submit">Change the password</button>
|
||||
</form>
|
||||
|
||||
<section class="card" id="two-factor">
|
||||
<h2>Two-factor sign-in</h2>
|
||||
{{if eq .Section "two-factor"}}<p class="error" role="alert">{{.Problem}}</p>{{end}}
|
||||
{{if .U.TwoFactor}}
|
||||
<p><span class="pill ok">On</span> Signing in asks for a code from your authenticator app.
|
||||
{{if lt .U.RecoveryLeft 3}}<strong>{{.U.RecoveryLeft}} recovery codes left:</strong> make new ones below.{{else}}{{.U.RecoveryLeft}} recovery codes left.{{end}}</p>
|
||||
<div class="cols">
|
||||
<form method="post" action="/settings/account/recovery-codes">
|
||||
<input type="text" name="username" value="{{.U.Email}}" autocomplete="username" hidden>
|
||||
<label>Your password <input type="password" name="current" autocomplete="current-password" required></label>
|
||||
<button type="submit" class="secondary">New recovery codes</button>
|
||||
</form>
|
||||
<form method="post" action="/settings/account/two-factor/off">
|
||||
<input type="text" name="username" value="{{.U.Email}}" autocomplete="username" hidden>
|
||||
<label>Your password <input type="password" name="current" autocomplete="current-password" required></label>
|
||||
<button type="submit" class="secondary danger">Turn it off</button>
|
||||
</form>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>Off. With it on, signing in asks for your password and a code from an authenticator app on your phone (such as Aegis, 2FAS, Google Authenticator or 1Password), so a stolen password isn't enough.</p>
|
||||
<a class="button" href="/settings/account/two-factor">Turn it on</a>
|
||||
{{end}}
|
||||
</section>
|
||||
|
||||
<section class="card" id="sessions">
|
||||
<h2>Where you're signed in</h2>
|
||||
<table class="list">
|
||||
<thead><tr><th>Browser</th><th>From</th><th>Signed in</th><th>Last used</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
{{range .Sessions}}<tr>
|
||||
<td>{{if .UserAgent}}{{truncate 60 .UserAgent}}{{else}}<span class="muted">unknown</span>{{end}}{{if .This}} <span class="pill">this one</span>{{end}}</td>
|
||||
<td>{{.IP}}</td><td>{{ago .Created}}</td><td>{{ago .Seen}}</td>
|
||||
<td><form class="inline" method="post" action="/settings/account/sessions/{{.ID}}/end"><button type="submit" class="secondary small">Sign out</button></form></td>
|
||||
</tr>{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{if gt (len .Sessions) 1}}<form method="post" action="/settings/account/sessions/end-others"><button type="submit" class="secondary">Sign out everywhere else</button></form>{{end}}
|
||||
</section>
|
||||
{{end}}{{template "settings-end"}}{{end}}
|
||||
Reference in New Issue
Block a user