mirror of
https://github.com/1f349/lavender.git
synced 2025-04-14 06:55:55 +01:00
Add fmt.Stringer to auth.Provider
This commit is contained in:
parent
49cf77d681
commit
2cfec4fe37
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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 == "" {
|
||||
|
@ -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{}{})
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user