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>
This commit is contained in:
2026-11-25 09:07:32 -07:00
co-authored by Claude Opus 5.5
parent 8040512a18
commit 47a504b7b2
18 changed files with 1220 additions and 15 deletions
+54
View File
@@ -0,0 +1,54 @@
{{define "content"}}{{template "settings-start" .}}{{with .Data}}{{$u := .M}}
<p><a href="/settings/users">← Users</a></p>
<h2>{{if $u.Name}}{{$u.Name}}{{else}}{{$u.Email}}{{end}}</h2>
<p class="lede">{{$u.Email}}{{with $u.Title}} · {{.}}{{end}} · {{template "user-status" $u}}</p>
{{with .Problem}}<p class="error" role="alert">{{.}}</p>{{end}}
<section class="card">
<dl class="facts">
<dt>Access</dt><dd>{{$u.Access}}</dd>
<dt>Joined</dt><dd>{{if eq $u.Status "invited"}}Not yet{{else}}{{$u.Created.Local.Format "2 Jan 2006"}}{{end}}</dd>
<dt>Last signed in</dt><dd>{{ago $u.SignedIn}}{{if .SessionsN}} · signed in on {{.SessionsN}} {{if eq .SessionsN 1}}browser{{else}}browsers{{end}}{{end}}</dd>
<dt>Two-factor sign-in</dt><dd>{{if $u.TwoFactor}}On, {{$u.RecoveryLeft}} recovery codes left{{else}}Off{{end}}</dd>
{{if $u.FailedSignIns}}<dt>Failed sign-ins</dt><dd>{{$u.FailedSignIns}} in a row{{if $u.Locked}}, locked {{ago $u.LockedAt}}{{end}}</dd>{{end}}
</dl>
</section>
{{if eq (print $u.Role) "owner"}}
<section class="card"><p class="help">The owner can do everything; their account can only be changed by them, under Settings → Your account.</p></section>
{{else if .Me}}
<section class="card"><p class="help">This is you: another admin changes your access. Your own settings are under <a href="/settings/account">Your account</a>.</p></section>
{{else}}
<form class="card" method="post" action="/settings/users/{{$u.ID}}/access">
{{template "access-fields" (dict "Role" $u.Role "Modules" $u.Modules "Grants" .Grants)}}
<button type="submit">Save</button>
</form>
<section class="card">
<h2>Account</h2>
<div class="actions">
{{if eq $u.Status "invited"}}
<form class="inline" method="post" action="/settings/users/{{$u.ID}}/resend"><button type="submit" class="secondary">Send the invitation again</button></form>
<form class="inline" method="post" action="/settings/users/{{$u.ID}}/withdraw"><button type="submit" class="secondary danger">Withdraw the invitation</button></form>
{{else if eq $u.Status "disabled"}}
<form class="inline" method="post" action="/settings/users/{{$u.ID}}/enable"><button type="submit" class="secondary">Turn the account back on</button></form>
{{else}}
{{if $u.Locked}}<form class="inline" method="post" action="/settings/users/{{$u.ID}}/unlock"><button type="submit">Unlock</button></form>{{end}}
{{if .SessionsN}}<form class="inline" method="post" action="/settings/users/{{$u.ID}}/sign-out"><button type="submit" class="secondary">Sign them out everywhere</button></form>{{end}}
{{if $u.TwoFactor}}<form class="inline" method="post" action="/settings/users/{{$u.ID}}/reset-two-factor"><button type="submit" class="secondary">Reset two-factor sign-in</button></form>{{end}}
<form class="inline" method="post" action="/settings/users/{{$u.ID}}/disable"><button type="submit" class="secondary danger">Turn the account off</button></form>
{{end}}
</div>
{{if $u.TwoFactor}}<p class="help">Reset two-factor sign-in for someone who lost their phone and their recovery codes: they sign in with their password alone, then turn it on again. Make sure it's really them asking.</p>{{end}}
<p class="help">Turning an account off signs them out and keeps their name on what they did; they can be turned back on.</p>
</section>
{{if ne $u.Status "invited"}}
<form class="card danger-zone" method="post" action="/settings/users/{{$u.ID}}/remove">
<h2>Remove</h2>
<p class="help">Removes the account for good. What they wrote stays.</p>
<button type="submit" class="danger">Remove {{if $u.Name}}{{$u.Name}}{{else}}{{$u.Email}}{{end}}</button>
</form>
{{end}}
{{end}}
{{end}}{{template "settings-end"}}{{end}}