Files
supermarket/internal/web/templates/account.html
T
davidandClaude Opus 5.5 47a504b7b2 Phase 10, part 4: inviting users, and what admins can change
Settings → Users lists everyone with their access and status. Admins
invite people by email (a link for 7 days), as admins or as members with
modules each to view or edit; the invitation's page sets the password,
profile and emails wanted. Admins can resend or withdraw invitations,
change access, turn accounts off and on, unlock, reset two-factor, sign
someone out, and remove them; never the owner, nor themselves. Your
account gets the emails wanted and a photo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:07:32 -07:00

90 lines
5.3 KiB
HTML

{{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>
{{if .Emails}}<fieldset>
<legend>Emails you'd like</legend>
{{$u := .U}}{{range .Emails}}<label class="check"><input type="checkbox" name="emails" value="{{.ID}}" {{if has $u.Emails .ID}}checked{{end}}> <span>{{.Name}} <span class="help">{{.Help}}</span></span></label>{{end}}
</fieldset>{{end}}
<button type="submit">Save</button>
</form>
{{if .Photos}}
<section class="card" id="photo">
<h2>Photo</h2>
<div class="photo-row">
{{if .U.Photo}}<img class="avatar large" src="/users/{{.U.ID}}/photo" alt="Your photo" width="64" height="64">{{else}}<span class="avatar large none" aria-hidden="true">{{slice .U.Email 0 1}}</span>{{end}}
<form method="post" action="/settings/account/photo" enctype="multipart/form-data" class="inline-form">
<input type="file" name="photo" accept="image/png,image/jpeg,image/webp,image/gif" required>
<button type="submit" class="secondary">Upload</button>
</form>
{{if .U.Photo}}<form method="post" action="/settings/account/photo?remove=1"><button type="submit" class="secondary small">Remove</button></form>{{end}}
</div>
<p class="help">Shown beside your name to the team. A square picture of 2 MB or less.</p>
</section>
{{end}}
<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}}