diff --git a/handlers/user.go b/handlers/user.go index 506f379..977ca7e 100644 --- a/handlers/user.go +++ b/handlers/user.go @@ -80,7 +80,7 @@ func account(s *service.Service, w http.ResponseWriter, r *http.Request) httputi http.Redirect(w, r, "/", http.StatusSeeOther) return nil } - passkeySettings, err := s.PasskeySettings(r.Context(), user.KTHID) + passkeys, err := s.ListPasskeysForUser(r.Context(), user.KTHID) if err != nil { return err } @@ -88,7 +88,7 @@ func account(s *service.Service, w http.ResponseWriter, r *http.Request) httputi if err != nil { return err } - return templates.Account(*user, passkeySettings, isAdmin) + return templates.Account(*user, passkeys, isAdmin) } func acceptInvite(s *service.Service, w http.ResponseWriter, r *http.Request) httputil.ToResponse { diff --git a/pkg/static/public/style.dist.css b/pkg/static/public/style.dist.css index a381dee..8c6e5f4 100644 --- a/pkg/static/public/style.dist.css +++ b/pkg/static/public/style.dist.css @@ -570,6 +570,10 @@ html { grid-column: 1 / -1; } +.mt-1 { + margin-top: 0.25rem; +} + .block { display: block; } @@ -626,6 +630,10 @@ html { min-height: 100vh; } +.w-16 { + width: 4rem; +} + .w-3\/5 { width: 60%; } @@ -654,6 +662,10 @@ html { max-width: calc(100vw - 2rem); } +.max-w-lg { + max-width: 32rem; +} + .shrink-0 { flex-shrink: 0; } @@ -662,10 +674,6 @@ html { flex-grow: 1; } -.basis-full { - flex-basis: 100%; -} - .select-none { -webkit-user-select: none; -moz-user-select: none; @@ -712,6 +720,14 @@ html { gap: 1rem; } +.gap-8 { + gap: 2rem; +} + +.overflow-auto { + overflow: auto; +} + .rounded { border-radius: 0.25rem; } @@ -835,6 +851,11 @@ html { line-height: 1.25rem; } +.text-xl { + font-size: 1.25rem; + line-height: 1.75rem; +} + .uppercase { text-transform: uppercase; } @@ -844,6 +865,21 @@ html { color: rgb(245 245 245 / var(--tw-text-opacity)); } +.text-cerise-regular { + --tw-text-opacity: 1; + color: rgb(232 61 132 / var(--tw-text-opacity)); +} + +.text-cerise-strong { + --tw-text-opacity: 1; + color: rgb(238 42 123 / var(--tw-text-opacity)); +} + +.text-cerise-light { + --tw-text-opacity: 1; + color: rgb(236 95 153 / var(--tw-text-opacity)); +} + .outline-none { outline: 2px solid transparent; outline-offset: 2px; @@ -1023,6 +1059,10 @@ html { padding-right: 0.75rem; } +.\[\&\>a\]\:shrink-0>a { + flex-shrink: 0; +} + .\[\&\>a\]\:items-center>a { align-items: center; } diff --git a/service/passkey.go b/service/passkey.go index 377450b..ba5cd2f 100644 --- a/service/passkey.go +++ b/service/passkey.go @@ -42,11 +42,3 @@ func (s *Service) ListPasskeysForUser(ctx context.Context, kthid string) ([]mode func (s *Service) PasskeyLogin() func() templ.Component { return func() templ.Component { return templates.PasskeyLoginForm("", nil) } } - -func (s *Service) PasskeySettings(ctx context.Context, kthid string) (func() templ.Component, error) { - passkeys, err := s.ListPasskeysForUser(ctx, kthid) - if err != nil { - return nil, err - } - return func() templ.Component { return templates.PasskeySettings(passkeys) }, nil -} diff --git a/templates/admin.templ b/templates/admin.templ index 0a3405f..f3a028b 100644 --- a/templates/admin.templ +++ b/templates/admin.templ @@ -1,30 +1,16 @@ package templates -import ( - "fmt" - "github.com/datasektionen/logout/pkg/static" -) +import "fmt" + +templ adminNav() { + Members + OIDC Clients + Invites +} templ AdminPage() { - @page() { - -
-
- { children... } -
-
+ @page(nav(true)) { + { children... } } } @@ -85,23 +71,3 @@ templ UploadProgress(progress float64) { templ UploadMessage(message string, isErr bool) {

{ message }

} - -var input = ` - border border-neutral-500 grow - outline-none focus:border-cerise-strong hover:border-cerise-light - bg-slate-800 p-1.5 rounded h-8 -` - -var button = ` - bg-[#3f4c66] p-1 h-8 block rounded border text-center - select-none border-transparent outline-none - focus:border-cerise-strong hover:border-cerise-light -` - -var roundButton = ` - bg-[#3f4c66] shrink-0 h-5 w-5 rounded-full - grid place-items-center pointer - border border-transparent outline-none focus:border-cerise-strong hover:border-cerise-light relative - [&>img]:w-3/5 [&>img]:h-3/5 [&>img]:invert - [&>p]:text-center [&>p]:leading-none -` diff --git a/templates/admin_invites_templ.go b/templates/admin_invites_templ.go index b6fd436..e14e870 100644 --- a/templates/admin_invites_templ.go +++ b/templates/admin_invites_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package templates //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/templates/admin_oidc_clients_templ.go b/templates/admin_oidc_clients_templ.go index 4264666..70366f2 100644 --- a/templates/admin_oidc_clients_templ.go +++ b/templates/admin_oidc_clients_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package templates //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/templates/admin_templ.go b/templates/admin_templ.go index fb54a54..9ed357b 100644 --- a/templates/admin_templ.go +++ b/templates/admin_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package templates //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -8,12 +8,9 @@ package templates import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import ( - "fmt" - "github.com/datasektionen/logout/pkg/static" -) +import "fmt" -func AdminPage() templ.Component { +func adminNav() 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 { @@ -34,7 +31,36 @@ func AdminPage() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Members OIDC Clients Invites") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func AdminPage() 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) + templ_7745c5c3_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -46,29 +72,13 @@ func AdminPage() templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + templ_7745c5c3_Err = templ_7745c5c3_Var2.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = page().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = page(nav(true)).Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -92,12 +102,12 @@ func Members() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var3 := templ.GetChildren(ctx) - if templ_7745c5c3_Var3 == nil { - templ_7745c5c3_Var3 = templ.NopComponent + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -127,7 +137,7 @@ func Members() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = AdminPage().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = AdminPage().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -151,17 +161,17 @@ func uploadForm() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var5 := templ.GetChildren(ctx) - if templ_7745c5c3_Var5 == nil { - templ_7745c5c3_Var5 = templ.NopComponent + templ_7745c5c3_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var6 = []any{button + "h-auto"} - templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var6...) + var templ_7745c5c3_Var7 = []any{button + "h-auto"} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var7...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -169,12 +179,12 @@ func uploadForm() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var6).String()) + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var7).String()) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `admin.templ`, Line: 1, Col: 0} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -202,9 +212,9 @@ func UploadStatus(withStuff bool) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) if withStuff { @@ -238,9 +248,9 @@ func UploadProgress(progress float64) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var9 := templ.GetChildren(ctx) - if templ_7745c5c3_Var9 == nil { - templ_7745c5c3_Var9 = templ.NopComponent + templ_7745c5c3_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
img]:w-3/5 [&>img]:h-3/5 [&>img]:invert - [&>p]:text-center [&>p]:leading-none -` - var _ = templruntime.GeneratedTemplate diff --git a/templates/layout.templ b/templates/layout.templ index 78ee6a0..cf1afe1 100644 --- a/templates/layout.templ +++ b/templates/layout.templ @@ -1,6 +1,11 @@ package templates -templ page() { +import ( + "github.com/datasektionen/logout/pkg/static" + "github.com/datasektionen/logout/pkg/config" +) + +templ base() { @@ -10,6 +15,7 @@ templ page() { + @base64Helpers() if config.Config.Dev { @@ -22,8 +28,39 @@ templ page() { } +templ page(navItems templ.Component) { + @base() { + +
+
+ { children... } +
+
+ } +} + +templ nav(includeAdmin bool) { + Account + if includeAdmin { + @adminNav() + } + Log out +} + templ modal() { - @page() { + @base() {
{ children... } @@ -32,6 +69,26 @@ templ modal() { } } +var input = ` + border border-neutral-500 grow + outline-none focus:border-cerise-strong hover:border-cerise-light + bg-slate-800 p-1.5 rounded h-8 +` + +var button = ` + bg-[#3f4c66] p-1 h-8 block rounded border text-center + select-none border-transparent outline-none + focus:border-cerise-strong hover:border-cerise-light +` + +var roundButton = ` + bg-[#3f4c66] shrink-0 h-5 w-5 rounded-full + grid place-items-center pointer + border border-transparent outline-none focus:border-cerise-strong hover:border-cerise-light relative + [&>img]:w-3/5 [&>img]:h-3/5 [&>img]:invert + [&>p]:text-center [&>p]:leading-none +` + templ base64Helpers() { ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Logout") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -59,7 +64,7 @@ func page() templ.Component { }) } -func modal() templ.Component { +func page(navItems templ.Component) 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 { @@ -92,7 +97,23 @@ func modal() templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -106,7 +127,7 @@ func modal() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = page().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -114,7 +135,7 @@ func modal() templ.Component { }) } -func base64Helpers() templ.Component { +func nav(includeAdmin bool) 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 { @@ -135,6 +156,120 @@ func base64Helpers() templ.Component { templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Account ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if includeAdmin { + templ_7745c5c3_Err = adminNav().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Log out") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func modal() 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) + templ_7745c5c3_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + 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) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var5.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = base().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var input = ` + border border-neutral-500 grow + outline-none focus:border-cerise-strong hover:border-cerise-light + bg-slate-800 p-1.5 rounded h-8 +` + +var button = ` + bg-[#3f4c66] p-1 h-8 block rounded border text-center + select-none border-transparent outline-none + focus:border-cerise-strong hover:border-cerise-light +` + +var roundButton = ` + bg-[#3f4c66] shrink-0 h-5 w-5 rounded-full + grid place-items-center pointer + border border-transparent outline-none focus:border-cerise-strong hover:border-cerise-light relative + [&>img]:w-3/5 [&>img]:h-3/5 [&>img]:invert + [&>p]:text-center [&>p]:leading-none +` + +func base64Helpers() 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) + templ_7745c5c3_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err diff --git a/templates/passkey.templ b/templates/passkey.templ index 471aecf..8e18393 100644 --- a/templates/passkey.templ +++ b/templates/passkey.templ @@ -91,7 +91,7 @@ templ PasskeyLoginForm(kthid string, credAss *protocol.CredentialAssertion) { } templ ShowPasskey(passkey models.Passkey) { -
  • +
  • { passkey.Name } diff --git a/templates/passkey_templ.go b/templates/passkey_templ.go index 9cfe025..d38be71 100644 --- a/templates/passkey_templ.go +++ b/templates/passkey_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package templates //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -135,7 +135,7 @@ func ShowPasskey(passkey models.Passkey) templ.Component { templ_7745c5c3_Var6 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -190,7 +190,7 @@ func PasskeySettings(passkeys []models.Passkey) templ.Component { templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Passkeys:

      ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

      Passkeys:

        ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -200,7 +200,7 @@ func PasskeySettings(passkeys []models.Passkey) templ.Component { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
      ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -236,7 +236,7 @@ func AddPasskeyForm(cc *protocol.CredentialCreation) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(templ.JSONString(cc)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `passkey.templ`, Line: 135, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `passkey.templ`, Line: 136, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { diff --git a/templates/user.templ b/templates/user.templ index 7190e2b..5418e4f 100644 --- a/templates/user.templ +++ b/templates/user.templ @@ -2,6 +2,7 @@ package templates import ( "github.com/datasektionen/logout/models" + "time" ) templ Index(passkeyLogin func() templ.Component, devLogin func() templ.Component) { @@ -23,33 +24,39 @@ templ Index(passkeyLogin func() templ.Component, devLogin func() templ.Component } } -templ Account(user models.User, passkeySettings func() templ.Component, isAdmin bool) { - @modal() { -
    -
    -

    { user.FirstName } { user.FamilyName } ({ user.KTHID })

    - if isAdmin { - - } - -
    - @passkeySettings() +templ Account(user models.User, passkeys []models.Passkey, isAdmin bool) { + @page(nav(isAdmin)) { +
    +
    +
    +

    Name

    +

    { user.FirstName } { user.FamilyName }

    +
    +
    +

    Username

    +

    { user.KTHID }

    +
    +
    +

    Email address

    +

    { user.Email }

    +
    + + +
    + + + +
    + if user.MemberTo == (time.Time{}) { +

    Not a chapter member

    + } else if user.MemberTo.Before(time.Now()) { +

    Was a chapter member until { user.MemberTo.Format(time.DateOnly) }

    + } else { +

    Chapter member until { user.MemberTo.Format(time.DateOnly) }

    + } +
    +
    + @PasskeySettings(passkeys)
    } } diff --git a/templates/user_templ.go b/templates/user_templ.go index ff536c2..a13228f 100644 --- a/templates/user_templ.go +++ b/templates/user_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package templates //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/datasektionen/logout/models" + "time" ) func Index(passkeyLogin func() templ.Component, devLogin func() templ.Component) templ.Component { @@ -71,7 +72,7 @@ func Index(passkeyLogin func() templ.Component, devLogin func() templ.Component) }) } -func Account(user models.User, passkeySettings func() templ.Component, isAdmin bool) templ.Component { +func Account(user models.User, passkeys []models.Passkey, isAdmin bool) 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 { @@ -104,14 +105,14 @@ func Account(user models.User, passkeySettings func() templ.Component, isAdmin b }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Name

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.FirstName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 30, Col: 42} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 33, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -124,40 +125,146 @@ func Account(user models.User, passkeySettings func() templ.Component, isAdmin b var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(user.FamilyName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 30, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 33, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" (") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Username

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(user.KTHID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 30, Col: 78} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 37, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(")

    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Email address

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - if isAdmin { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 41, Col: 20} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("


    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var9 = []any{input + " w-16"} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var9...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var12 = []any{button} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var12...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if user.MemberTo == (time.Time{}) { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Not a chapter member

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else if user.MemberTo.Before(time.Now()) { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Was a chapter member until ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(user.MemberTo.Format(time.DateOnly)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 53, Col: 73} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Chapter member until ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var15 string + templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(user.MemberTo.Format(time.DateOnly)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `user.templ`, Line: 55, Col: 67} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = passkeySettings().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = PasskeySettings(passkeys).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -167,7 +274,7 @@ func Account(user models.User, passkeySettings func() templ.Component, isAdmin b } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = modal().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = page(nav(isAdmin)).Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -191,12 +298,12 @@ func AcceptInvite() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent + templ_7745c5c3_Var16 := templ.GetChildren(ctx) + if templ_7745c5c3_Var16 == nil { + templ_7745c5c3_Var16 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var17 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -214,7 +321,7 @@ func AcceptInvite() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = modal().Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = modal().Render(templ.WithChildren(ctx, templ_7745c5c3_Var17), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }