Add fmt.Stringer to auth.Provider

This commit is contained in:
Melon 2025-03-14 14:46:54 +00:00
parent 49cf77d681
commit 2cfec4fe37
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
6 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package auth
import (
"fmt"
"github.com/1f349/lavender/auth/process"
)
@ -11,4 +12,6 @@ type Provider interface {
// Name defines a string value for the provider.
Name() string
fmt.Stringer
}

View File

@ -33,6 +33,8 @@ func (b *Base) AccessState() process.State { return process.StateUnauthorized }
func (b *Base) Name() string { return "base" }
func (b *Base) String() string { return "%Provider(base)" }
func (b *Base) RenderTemplate(ctx authContext.TemplateContext) error {
type s struct {
LoginNameMemory bool

View File

@ -58,6 +58,8 @@ func (o OAuthLogin) AccessState() process.State { return process.StateUnauthoriz
func (o OAuthLogin) Name() string { return "oauth" }
func (o OAuthLogin) String() string { return "%Provider(oauth)" }
func (o OAuthLogin) AttemptLogin(ctx authContext.FormContext) error {
rCtx := ctx.Context()

View File

@ -32,6 +32,8 @@ func (o *OtpLogin) AccessState() process.State { return process.StateBasic }
func (o *OtpLogin) Name() string { return "otp" }
func (o *OtpLogin) String() string { return "%Provider(otp)" }
func (o *OtpLogin) RenderTemplate(ctx authContext.TemplateContext) error {
user := ctx.User()
if user == nil || user.Subject == "" {

View File

@ -25,6 +25,8 @@ func (p *PasskeyLogin) AccessState() process.State { return process.StateUnautho
func (p *PasskeyLogin) Name() string { return "passkey" }
func (p *PasskeyLogin) String() string { return "%Provider(passkey)" }
func (p *PasskeyLogin) RenderButtonTemplate(ctx authContext.TemplateContext) {
// provide something non-nil
ctx.Render(struct{}{})

View File

@ -29,6 +29,8 @@ func (p *PasswordLogin) AccessState() process.State { return process.StateBase }
func (p *PasswordLogin) Name() string { return "password" }
func (p *PasswordLogin) String() string { return "%Provider(password)" }
func (p *PasswordLogin) RenderTemplate(ctx authContext.TemplateContext) error {
// TODO(melon): rewrite this
req := ctx.Request()