From 7b063d2cd892397b70673f3581cac5155cfeb2c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Sun, 22 Nov 2026 00:35:20 +0100 Subject: [PATCH] feat(api): accept recovery codes as second factor and let users regenerate them Enabling TOTP returns ten codes that are shown once. Disabling TOTP and regenerating codes require the password plus a current code. Closes #40 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3 --- internal/api/auth.go | 9 +- internal/api/me.go | 136 +++++++++++---- internal/api/pages.go | 11 +- internal/api/recovery_test.go | 87 ++++++++++ internal/api/server.go | 1 + internal/api/sso_test.go | 5 + internal/i18n/i18n_test.go | 5 + internal/i18n/locales/de.json | 11 +- internal/i18n/locales/en.json | 11 +- internal/web/assets/app.js | 10 ++ internal/web/console.templ | 45 ++++- internal/web/console_templ.go | 302 ++++++++++++++++++++++++++-------- 12 files changed, 510 insertions(+), 123 deletions(-) create mode 100644 internal/api/recovery_test.go diff --git a/internal/api/auth.go b/internal/api/auth.go index f650cd4..8f9e229 100644 --- a/internal/api/auth.go +++ b/internal/api/auth.go @@ -167,12 +167,17 @@ func (s *Server) login(c *gin.Context) { s.finishLogin(c, user.ID) } +// secondFactorRequest carries a TOTP code or a recovery code. +type secondFactorRequest struct { + Code string `json:"code" binding:"required,max=32"` +} + type totpRequest struct { Code string `json:"code" binding:"required,len=6,numeric"` } func (s *Server) loginTOTP(c *gin.Context) { - var req totpRequest + var req secondFactorRequest if !bind(c, &req) { return } @@ -195,7 +200,7 @@ func (s *Server) loginTOTP(c *gin.Context) { internalError(c, err) return } - ok, err := s.verifyUserTOTP(ctx, userID, req.Code) + ok, err := s.verifySecondFactor(ctx, userID, req.Code) if err != nil { internalError(c, err) return diff --git a/internal/api/me.go b/internal/api/me.go index d60e2b6..4d26dbd 100644 --- a/internal/api/me.go +++ b/internal/api/me.go @@ -37,6 +37,7 @@ type meView struct { Orgs []orgView `json:"orgs"` // Set when an org the user belongs to enforces TOTP and the user has none. TOTPEnrollmentRequired bool `json:"totp_enrollment_required"` + RecoveryCodesLeft int `json:"recovery_codes_left"` } func (s *Server) loadMe(ctx context.Context, sess *auth.Session) (meView, error) { @@ -46,11 +47,15 @@ func (s *Server) loadMe(ctx context.Context, sess *auth.Session) (meView, error) if err != nil { return err } + left, err := q.CountUnusedRecoveryCodes(ctx, sess.UserID) + if err != nil { + return err + } orgs, err := q.ListUserOrgs(ctx, sess.UserID) if err != nil { return err } - me = meView{ID: u.ID, Email: u.Email, DisplayName: u.DisplayName, TOTP: u.TotpSecret != nil, ActiveOrg: sess.OrgID, Orgs: []orgView{}} + me = meView{ID: u.ID, Email: u.Email, DisplayName: u.DisplayName, TOTP: u.TotpSecret != nil, ActiveOrg: sess.OrgID, Orgs: []orgView{}, RecoveryCodesLeft: int(left)} for _, o := range orgs { me.Orgs = append(me.Orgs, orgView{ID: o.ID, Slug: o.Slug, Name: o.Name, IsOwner: o.IsOwner, RequireTOTP: o.RequireTotp}) if o.RequireTotp && !me.TOTP { @@ -154,32 +159,85 @@ func (s *Server) totpEnable(c *gin.Context) { return } sealedSecret := s.keys.Seal([]byte(secret), sess.UserID[:]) + codes := auth.NewRecoveryCodes() err = s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error { - return q.EnableTOTP(ctx, store.EnableTOTPParams{ID: sess.UserID, TotpSecret: sealedSecret}) + if err := q.EnableTOTP(ctx, store.EnableTOTPParams{ID: sess.UserID, TotpSecret: sealedSecret}); err != nil { + return err + } + return replaceRecoveryCodes(ctx, q, sess.UserID, codes) }) if err != nil { internalError(c, err) return } _ = s.rdb.Del(ctx, totpSetupKey(sess.UserID)).Err() - c.Status(http.StatusNoContent) + c.JSON(http.StatusOK, gin.H{"recovery_codes": codes}) } -type totpDisableRequest struct { +func replaceRecoveryCodes(ctx context.Context, q *store.Queries, user uuid.UUID, codes []string) error { + if err := q.DeleteRecoveryCodes(ctx, user); err != nil { + return err + } + rows := make([]store.InsertRecoveryCodesParams, len(codes)) + for i, c := range codes { + rows[i] = store.InsertRecoveryCodesParams{UserID: user, CodeHash: auth.HashRecoveryCode(auth.NormalizeRecoveryCode(c))} + } + _, err := q.InsertRecoveryCodes(ctx, rows) + return err +} + +// reauthRequest confirms a sensitive change with the password and a second +// factor, so a hijacked session alone cannot weaken the account. +type reauthRequest struct { Password string `json:"password" binding:"required,max=1024"` - Code string `json:"code" binding:"required,len=6,numeric"` + Code string `json:"code" binding:"required,max=32"` +} + +// reauthenticate checks req for the session user and writes the error +// response itself when it fails. +func (s *Server) reauthenticate(c *gin.Context, req reauthRequest) bool { + ctx := c.Request.Context() + sess := auth.Current(c) + if !s.limit(c, "reauth:"+sess.UserID.String(), 5, 15*time.Minute) { + return false + } + var user store.User + err := s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error { + var err error + user, err = q.GetUser(ctx, sess.UserID) + return err + }) + if err != nil { + internalError(c, err) + return false + } + if user.PasswordHash == nil { + fail(c, http.StatusConflict, "no_password") + return false + } + if ok, _, err := auth.VerifyPassword(*user.PasswordHash, req.Password); err != nil || !ok { + invalidCredentials(c) + return false + } + ok, err := s.verifySecondFactor(ctx, sess.UserID, req.Code) + if err != nil { + internalError(c, err) + return false + } + if !ok { + fail(c, http.StatusUnauthorized, "invalid_code") + return false + } + return true } func (s *Server) totpDisable(c *gin.Context) { - var req totpDisableRequest + var req reauthRequest if !bind(c, &req) { return } ctx := c.Request.Context() sess := auth.Current(c) - if !s.limit(c, "totp_disable:"+sess.UserID.String(), 5, 15*time.Minute) { - return - } me, err := s.loadMe(ctx, sess) if err != nil { internalError(c, err) @@ -191,33 +249,14 @@ func (s *Server) totpDisable(c *gin.Context) { return } } - var user store.User - err = s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error { - var err error - user, err = q.GetUser(ctx, sess.UserID) - return err - }) - if err != nil { - internalError(c, err) - return - } - if user.PasswordHash == nil { - fail(c, http.StatusConflict, "no_password") - return - } - if ok, _, err := auth.VerifyPassword(*user.PasswordHash, req.Password); err != nil || !ok { - invalidCredentials(c) - return - } - if ok, err := s.verifyUserTOTP(ctx, sess.UserID, req.Code); err != nil { - internalError(c, err) - return - } else if !ok { - fail(c, http.StatusUnauthorized, "invalid_code") + if !s.reauthenticate(c, req) { return } err = s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error { - return q.DisableTOTP(ctx, sess.UserID) + if err := q.DisableTOTP(ctx, sess.UserID); err != nil { + return err + } + return q.DeleteRecoveryCodes(ctx, sess.UserID) }) if err != nil { internalError(c, err) @@ -226,9 +265,38 @@ func (s *Server) totpDisable(c *gin.Context) { c.Status(http.StatusNoContent) } +func (s *Server) regenerateRecoveryCodes(c *gin.Context) { + var req reauthRequest + if !bind(c, &req) || !s.reauthenticate(c, req) { + return + } + ctx := c.Request.Context() + sess := auth.Current(c) + codes := auth.NewRecoveryCodes() + err := s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error { + return replaceRecoveryCodes(ctx, q, sess.UserID, codes) + }) + if err != nil { + internalError(c, err) + return + } + c.JSON(http.StatusOK, gin.H{"recovery_codes": codes}) +} + var errNoTOTP = errors.New("api: user has no totp") -func (s *Server) verifyUserTOTP(ctx context.Context, userID uuid.UUID, code string) (bool, error) { +// verifySecondFactor accepts a current TOTP code or an unused recovery code, +// which is consumed. +func (s *Server) verifySecondFactor(ctx context.Context, userID uuid.UUID, code string) (bool, error) { + if rc := auth.NormalizeRecoveryCode(code); rc != "" { + var n int64 + err := s.db.Tx(ctx, tenant.User(userID), func(q *store.Queries) error { + var err error + n, err = q.UseRecoveryCode(ctx, store.UseRecoveryCodeParams{UserID: userID, CodeHash: auth.HashRecoveryCode(rc)}) + return err + }) + return n == 1, err + } var user store.User err := s.db.Tx(ctx, tenant.User(userID), func(q *store.Queries) error { var err error diff --git a/internal/api/pages.go b/internal/api/pages.go index 398e84f..33c8b26 100644 --- a/internal/api/pages.go +++ b/internal/api/pages.go @@ -165,11 +165,12 @@ func (s *Server) ssoSettingsPage(c *gin.Context) { func toWebMe(m meView) web.Me { out := web.Me{ - Email: m.Email, - DisplayName: m.DisplayName, - TOTP: m.TOTP, - ActiveOrg: m.ActiveOrg.String(), - TOTPMissing: m.TOTPEnrollmentRequired, + Email: m.Email, + DisplayName: m.DisplayName, + TOTP: m.TOTP, + ActiveOrg: m.ActiveOrg.String(), + TOTPMissing: m.TOTPEnrollmentRequired, + RecoveryCodesLeft: m.RecoveryCodesLeft, } for _, o := range m.Orgs { out.Orgs = append(out.Orgs, web.Org{ID: o.ID.String(), Name: o.Name, Slug: o.Slug, IsOwner: o.IsOwner}) diff --git a/internal/api/recovery_test.go b/internal/api/recovery_test.go new file mode 100644 index 0000000..58f0368 --- /dev/null +++ b/internal/api/recovery_test.go @@ -0,0 +1,87 @@ +package api_test + +import ( + "net/http" + "testing" + "time" + + "github.com/pquerna/otp/totp" +) + +// enableTOTP turns on TOTP for b and returns the secret and recovery codes. +func (b *browser) enableTOTP() (string, []string) { + b.t.Helper() + st, setup := b.do("POST", "/api/v1/me/totp/setup", nil) + if st != http.StatusOK { + b.t.Fatalf("totp setup = %d %v", st, setup) + } + secret := setup["secret"].(string) + code, _ := totp.GenerateCode(secret, time.Now()) + st, body := b.do("POST", "/api/v1/me/totp/enable", map[string]any{"code": code}) + if st != http.StatusOK { + b.t.Fatalf("totp enable = %d %v", st, body) + } + var codes []string + for _, c := range body["recovery_codes"].([]any) { + codes = append(codes, c.(string)) + } + return secret, codes +} + +func TestRecoveryCodes(t *testing.T) { + e := newEnv(t) + email := uniq("r") + "@example.test" + owner := e.browser(t) + owner.signup(email, uniq("rec-")) + _, codes := owner.enableTOTP() + if len(codes) != 10 { + t.Fatalf("enable returned %d recovery codes, want 10", len(codes)) + } + + login := func(code string) (int, map[string]any) { + b := e.browser(t) + if st, body := b.do("POST", "/api/v1/auth/login", map[string]any{"email": email, "password": "correct horse battery"}); body["status"] != "totp_required" { + t.Fatalf("login = %d %v, want totp_required", st, body) + } + return b.do("POST", "/api/v1/auth/login/totp", map[string]any{"code": code}) + } + + if st, body := login(codes[0]); st != http.StatusOK { + t.Fatalf("login with recovery code = %d %v, want 200", st, body) + } + if st, _ := login(codes[0]); st != http.StatusUnauthorized { + t.Errorf("login with used recovery code = %d, want 401", st) + } + if st, _ := login(" " + upper(codes[1][:5]) + " " + codes[1][6:]); st != http.StatusOK { + t.Errorf("login with reformatted recovery code = %d, want 200", st) + } + if _, me := owner.do("GET", "/api/v1/me", nil); me["recovery_codes_left"] != float64(8) { + t.Errorf("recovery_codes_left = %v, want 8", me["recovery_codes_left"]) + } + + st, body := owner.do("POST", "/api/v1/me/totp/recovery-codes", map[string]any{"password": "correct horse battery", "code": codes[2]}) + if st != http.StatusOK || len(body["recovery_codes"].([]any)) != 10 { + t.Fatalf("regenerate = %d %v, want 200 with 10 codes", st, body) + } + if st, _ := login(codes[3]); st != http.StatusUnauthorized { + t.Errorf("login with code from replaced set = %d, want 401", st) + } + if st, _ := login(body["recovery_codes"].([]any)[0].(string)); st != http.StatusOK { + t.Errorf("login with code from new set = %d, want 200", st) + } + + st, _ = owner.do("POST", "/api/v1/me/totp/recovery-codes", map[string]any{"password": "wrong password!!", "code": codes[4]}) + if st != http.StatusUnauthorized { + t.Errorf("regenerate with wrong password = %d, want 401", st) + } +} + +func upper(s string) string { + b := []byte(s) + for i, c := range b { + if c >= 'a' && c <= 'z' { + b[i] = c - 32 + } + } + return string(b) +} diff --git a/internal/api/server.go b/internal/api/server.go index c0ba9d3..2687d31 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -83,6 +83,7 @@ func (s *Server) Mount(r gin.IRouter) { me.POST("/totp/setup", s.totpSetup) me.POST("/totp/enable", s.totpEnable) me.POST("/totp/disable", s.totpDisable) + me.POST("/totp/recovery-codes", s.regenerateRecoveryCodes) org := v1.Group("/org", auth.Require(), s.requireOwner()) org.GET("/sso", s.listSSOProviders) diff --git a/internal/api/sso_test.go b/internal/api/sso_test.go index 9c9d57d..0c3ace2 100644 --- a/internal/api/sso_test.go +++ b/internal/api/sso_test.go @@ -57,6 +57,11 @@ func newEnv(t *testing.T) *env { } rdb := redis.NewClient(opts) t.Cleanup(func() { _ = rdb.Close() }) + // UPTIME_TEST_REDIS_URL must name a database reserved for tests; clearing + // it resets rate limits left over from earlier runs. + if err := rdb.FlushDB(ctx).Err(); err != nil { + t.Fatalf("FLUSHDB failed: %v", err) + } key := make([]byte, 32) _, _ = rand.Read(key) diff --git a/internal/i18n/i18n_test.go b/internal/i18n/i18n_test.go index 998a6d6..c59d879 100644 --- a/internal/i18n/i18n_test.go +++ b/internal/i18n/i18n_test.go @@ -149,6 +149,11 @@ func TestT(t *testing.T) { if got, want := T(ctx, "error.password_too_short", "Min", 12), "Das Passwort braucht mindestens 12 Zeichen."; got != want { t.Errorf("T(de, password_too_short) = %q, want %q", got, want) } + for n, want := range map[int]string{1: "1 Wiederherstellungscode übrig", 3: "3 Wiederherstellungscodes übrig"} { + if got := T(ctx, "security.recovery.left", "Count", n); got != want { + t.Errorf("T(de, recovery.left, %d) = %q, want %q", n, got, want) + } + } if got, want := T(ctx, "no.such.key"), "no.such.key"; got != want { t.Errorf("T(missing) = %q, want %q", got, want) } diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index df5e12e..e0648c5 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -11,7 +11,7 @@ "auth.login.submit": "Weiter", "auth.login.title": "Anmelden", "auth.login.to_signup": "Registrieren", - "auth.login.totp_hint": "Code aus der Authenticator-App eingeben.", + "auth.login.totp_hint": "Code aus der Authenticator-App oder einen Wiederherstellungscode eingeben.", "auth.signup.submit": "Anlegen", "auth.signup.title": "Konto anlegen", "auth.signup.to_login": "Zur Anmeldung", @@ -61,6 +61,13 @@ "error.unsupported_locale": "Sprache wird nicht unterstützt.", "lang.de": "Deutsch", "lang.en": "English", + "security.recovery.left": { + "one": "{{.Count}} Wiederherstellungscode übrig", + "other": "{{.Count}} Wiederherstellungscodes übrig" + }, + "security.recovery.regenerate": "Neue Wiederherstellungscodes erzeugen", + "security.recovery.save_now": "Bewahre diese Wiederherstellungscodes sicher auf. Jeder funktioniert einmal, falls du deinen Authenticator verlierst. Sie werden nicht erneut angezeigt.", + "security.recovery.saved": "Ich habe sie gespeichert", "security.sso.heading": "Single Sign-on", "security.sso.link": "SSO-Anmeldung verknüpfen", "security.sso.linked": "SSO-Anmeldung verknüpft.", @@ -69,7 +76,7 @@ "security.totp.active": "aktiv", "security.totp.app_code": "Code aus der App", "security.totp.confirm": "Bestätigen", - "security.totp.current_code": "Aktueller Code", + "security.totp.current_code": "Aktueller Code oder Wiederherstellungscode", "security.totp.disable": "Deaktivieren", "security.totp.heading": "Zwei-Faktor (TOTP)", "security.totp.inactive": "nicht eingerichtet", diff --git a/internal/i18n/locales/en.json b/internal/i18n/locales/en.json index a480d22..9ca4d53 100644 --- a/internal/i18n/locales/en.json +++ b/internal/i18n/locales/en.json @@ -11,7 +11,7 @@ "auth.login.submit": "Continue", "auth.login.title": "Sign in", "auth.login.to_signup": "Sign up", - "auth.login.totp_hint": "Enter the code from your authenticator app.", + "auth.login.totp_hint": "Enter the code from your authenticator app or one of your recovery codes.", "auth.signup.submit": "Create", "auth.signup.title": "Create account", "auth.signup.to_login": "Back to sign in", @@ -61,6 +61,13 @@ "error.unsupported_locale": "Unsupported language.", "lang.de": "Deutsch", "lang.en": "English", + "security.recovery.left": { + "one": "{{.Count}} recovery code left", + "other": "{{.Count}} recovery codes left" + }, + "security.recovery.regenerate": "Generate new recovery codes", + "security.recovery.save_now": "Store these recovery codes somewhere safe. Each works once if you lose your authenticator. They will not be shown again.", + "security.recovery.saved": "I have saved them", "security.sso.heading": "Single sign-on", "security.sso.link": "Link SSO sign-in", "security.sso.linked": "SSO sign-in linked.", @@ -69,7 +76,7 @@ "security.totp.active": "active", "security.totp.app_code": "Code from the app", "security.totp.confirm": "Confirm", - "security.totp.current_code": "Current code", + "security.totp.current_code": "Current code or recovery code", "security.totp.disable": "Disable", "security.totp.heading": "Two-factor (TOTP)", "security.totp.inactive": "not set up", diff --git a/internal/web/assets/app.js b/internal/web/assets/app.js index 6ad947f..a95524c 100644 --- a/internal/web/assets/app.js +++ b/internal/web/assets/app.js @@ -44,6 +44,16 @@ button && (button.disabled = true); try { const res = await api.request({ method: form.dataset.method || "post", url, data: body }); + if (form.dataset.showCodes !== undefined && res.data?.recovery_codes) { + const out = form.querySelector("[data-recovery-output]"); + const list = out.querySelector("[data-recovery-list]"); + list.replaceChildren( + ...res.data.recovery_codes.map((c) => Object.assign(document.createElement("li"), { textContent: c })), + ); + for (const el of form.elements) el.disabled = true; + out.hidden = false; + return; + } if (res.data?.status === "totp_required" && totpStep) { form.querySelector('[data-step="password"]').hidden = true; totpStep.hidden = false; diff --git a/internal/web/console.templ b/internal/web/console.templ index fca2b8e..604d2a9 100644 --- a/internal/web/console.templ +++ b/internal/web/console.templ @@ -13,6 +13,8 @@ type Me struct { ActiveOrg string Orgs []Org TOTPMissing bool + // RecoveryCodesLeft counts unused TOTP recovery codes. + RecoveryCodesLeft int } // Org is one entry of the organization switcher. @@ -81,13 +83,29 @@ templ Security(p Page, me Me, identities []Identity, canLink bool) {

{ i18n.T(ctx, "security.totp.heading") }

if me.TOTP { -

● { i18n.T(ctx, "security.totp.active") }

-
- @formError() - @field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true) - @field(i18n.T(ctx, "security.totp.current_code"), "code", "text", "one-time-code", true) - @submit(i18n.T(ctx, "security.totp.disable")) -
+

● { i18n.T(ctx, "security.totp.active") }

+

= 3) }> + { i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft) } +

+
+ { i18n.T(ctx, "security.recovery.regenerate") } +
+ @formError() + @field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true) + @field(i18n.T(ctx, "security.totp.current_code"), "code", "text", "one-time-code", true) + @submit(i18n.T(ctx, "security.recovery.regenerate")) + @recoveryOutput() +
+
+
+ { i18n.T(ctx, "security.totp.disable") } +
+ @formError() + @field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true) + @field(i18n.T(ctx, "security.totp.current_code"), "code", "text", "one-time-code", true) + @submit(i18n.T(ctx, "security.totp.disable")) +
+
} else {

● { i18n.T(ctx, "security.totp.inactive") }

@@ -95,10 +113,11 @@ templ Security(p Page, me Me, identities []Identity, canLink bool) {
@@ -121,3 +140,13 @@ templ Security(p Page, me Me, identities []Identity, canLink bool) {
} } + +// recoveryOutput is filled by app.js with codes returned by the API; they +// are shown once and never rendered by the server. +templ recoveryOutput() { + +} diff --git a/internal/web/console_templ.go b/internal/web/console_templ.go index 3c16bfe..6f6c00c 100644 --- a/internal/web/console_templ.go +++ b/internal/web/console_templ.go @@ -22,6 +22,8 @@ type Me struct { ActiveOrg string Orgs []Org TOTPMissing bool + // RecoveryCodesLeft counts unused TOTP recovery codes. + RecoveryCodesLeft int } // Org is one entry of the organization switcher. @@ -79,7 +81,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(o.ID).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 34, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 36, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) if templ_7745c5c3_Err != nil { @@ -102,7 +104,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(o.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 34, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 36, Col: 73} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -125,7 +127,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(me.Orgs[0].Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 38, Col: 47} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 40, Col: 47} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -148,7 +150,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.sso")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 42, Col: 96} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 44, Col: 96} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -166,7 +168,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.security")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 44, Col: 105} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 46, Col: 105} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -179,7 +181,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 45, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 47, Col: 94} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -205,7 +207,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.totp_missing")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 53, Col: 42} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 55, Col: 42} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -218,7 +220,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.totp_missing_action")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 54, Col: 115} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 56, Col: 115} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -291,7 +293,7 @@ func Dashboard(p Page, me Me) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 67, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 69, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -304,7 +306,7 @@ func Dashboard(p Page, me Me) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.empty")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 68, Col: 76} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 70, Col: 76} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -366,7 +368,7 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 80, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 82, Col: 72} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -379,7 +381,7 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.heading")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 82, Col: 114} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 84, Col: 114} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -390,20 +392,123 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen return templ_7745c5c3_Err } if me.TOTP { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "

● ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "

● ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.active")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 84, Col: 98} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 86, Col: 98} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + { + templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer + templ_7745c5c3_Buffer := templ.GetBuffer() + var templ_7745c5c3_ElementScripts []templ.ComponentScript + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "

= 3)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var20...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var21 string + templ_7745c5c3_Var21, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var20).String()).Resolve(ctx) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 1, Col: 0} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_ElementScripts...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_ElementWriter) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, ">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var22 string + templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 88, Col: 75} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.regenerate")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 91, Col: 116} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = formError().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = field(i18n.T(ctx, "security.totp.current_code"), "code", "text", "one-time-code", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = submit(i18n.T(ctx, "security.recovery.regenerate")).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = recoveryOutput().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var24 string + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.disable")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 101, Col: 109} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -423,51 +528,51 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "

● ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

● ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.inactive")) + var templ_7745c5c3_Var25 string + templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.inactive")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 92, Col: 105} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 110, Col: 105} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "

") + templ_7745c5c3_Err = recoveryOutput().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var23 string - templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.heading")) + var templ_7745c5c3_Var28 string + templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.heading")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 108, Col: 113} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 127, Col: 113} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if len(identities) == 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var24 string - templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.none")) + var templ_7745c5c3_Var29 string + templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.none")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 110, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 129, Col: 73} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, id := range identities { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
    • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var25 string - templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(id.Provider) + var templ_7745c5c3_Var30 string + templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(id.Provider) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 114, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 133, Col: 69} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var26 string - templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(id.Email) + var templ_7745c5c3_Var31 string + templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(id.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 114, Col: 131} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 133, Col: 131} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "
    • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if canLink { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "\" class=\"inline-block border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var28 string - templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.link")) + var templ_7745c5c3_Var33 string + templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.link")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 119, Col: 190} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 138, Col: 190} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -611,4 +720,57 @@ func Security(p Page, me Me, identities []Identity, canLink bool) templ.Componen }) } +// recoveryOutput is filled by app.js with codes returned by the API; they +// are shown once and never rendered by the server. +func recoveryOutput() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + var _ = templruntime.GeneratedTemplate