Files
supermarket/internal/web/templates/account.html
T
davidandClaude Opus 5.5 bb4772637c Phase 10, part 7: posting accounts, and who may post to which
Social accounts become posting accounts: several per network, the
company's and each person's own, with their tokens kept per account. The
old sign-ins are adopted as the company's. Admins say who may post to which
(Settings → Posting accounts); a draft can go out from one account or a
copy to several, each recording who posted it and as what. Signing an
account out, or removing its owner, holds the posts scheduled to it and
tells whoever scheduled them.

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

104 lines
6.2 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>
{{if or .Posting .Connectable}}
<section class="card" id="posting">
<h2>Your posting accounts</h2>
<p class="help">Your own social accounts, to post as yourself. They're yours to post to; an admin can let others too. Signing one out takes it out of everyone's list, and posts scheduled to it come back to Posts.</p>
{{if .Posting}}<ul class="accounts">{{range .Posting}}
<li><strong>{{.Label}}</strong>{{if not .Expires.IsZero}} <span class="muted small">until {{.Expires.Local.Format "2 Jan 2006"}}</span>{{end}}
<form class="inline" method="post" action="/settings/account/posting/{{.ID}}/remove"><button type="submit" class="secondary small">Sign out</button></form></li>
{{end}}</ul>{{end}}
<div class="actions">{{range .Connectable}}
<form class="inline" method="post" action="/auth/{{.ID}}/start?for=me"><button type="submit" class="secondary">Connect your {{.Name}}</button></form>
{{end}}</div>
</section>
{{end}}
<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}}