Two-step sign-in: authenticator app, security keys and passkeys

This commit is contained in:
Daniel Redetzke
2026-10-04 21:55:53 +03:00
parent ebbc282073
commit 1fe9b4e619
11 changed files with 1590 additions and 41 deletions
+10 -9
View File
@@ -13,14 +13,15 @@ import (
// everyone changes their own password with the current one.
type userView struct {
ID string `json:"id"`
Username string `json:"username"`
Note string `json:"note"`
MustChangePassword bool `json:"mustChangePassword"`
Created time.Time `json:"created"`
LastLogin *tokenUse `json:"lastLogin"` // since the service started
Tokens int `json:"tokens"`
You bool `json:"you"`
ID string `json:"id"`
Username string `json:"username"`
Note string `json:"note"`
MustChangePassword bool `json:"mustChangePassword"`
Created time.Time `json:"created"`
LastLogin *tokenUse `json:"lastLogin"` // since the service started
Tokens int `json:"tokens"`
You bool `json:"you"`
MFA map[string]any `json:"mfa"` // {"totp": bool, "keys": n, "passkeys": n}
}
func (a *App) userView(c *Config, u *User, me string) userView {
@@ -30,7 +31,7 @@ func (a *App) userView(c *Config, u *User, me string) userView {
n++
}
}
return userView{u.ID, u.Username, u.Note, u.MustChangePassword, u.Created, a.auth.LastLogin(u.ID), n, u.ID == me}
return userView{u.ID, u.Username, u.Note, u.MustChangePassword, u.Created, a.auth.LastLogin(u.ID), n, u.ID == me, mfaSummary(u)}
}
// username names a user for lists, or "" if the ID is unknown.