mirror of
https://github.com/1f349/lavender.git
synced 2025-02-23 06:05:08 +00:00
Convert RenderButtonTemplate to TemplateContext
This commit is contained in:
parent
db0ad159fb
commit
7760129db2
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/1f349/lavender/url"
|
"github.com/1f349/lavender/url"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"html/template"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -101,11 +100,16 @@ func (o OAuthLogin) OAuthCallback(rw http.ResponseWriter, req *http.Request, inf
|
|||||||
redirect(rw, req)
|
redirect(rw, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o OAuthLogin) ButtonName() string { return o.Name() }
|
func (o OAuthLogin) RenderButtonTemplate(ctx authContext.TemplateContext) {
|
||||||
|
|
||||||
func (o OAuthLogin) RenderButtonTemplate(ctx context.Context, req *http.Request) template.HTML {
|
|
||||||
// o.authUrlBase("button")
|
// o.authUrlBase("button")
|
||||||
return "<div>OAuth Login Template</div>"
|
// provide something non-nil
|
||||||
|
ctx.Render(struct {
|
||||||
|
Href string
|
||||||
|
ButtonName string
|
||||||
|
}{
|
||||||
|
Href: o.authUrlBase("button").String(),
|
||||||
|
ButtonName: "Login with Unknown OAuth Button", // TODO: actually get the service name
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type oauthServiceLogin int
|
type oauthServiceLogin int
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package providers
|
package providers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"github.com/1f349/lavender/auth"
|
"github.com/1f349/lavender/auth"
|
||||||
"html/template"
|
"github.com/1f349/lavender/auth/authContext"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type passkeyLoginDB interface {
|
type passkeyLoginDB interface {
|
||||||
@ -24,6 +22,7 @@ func (p *PasskeyLogin) AccessState() auth.State { return auth.StateUnauthorized
|
|||||||
|
|
||||||
func (p *PasskeyLogin) Name() string { return "passkey" }
|
func (p *PasskeyLogin) Name() string { return "passkey" }
|
||||||
|
|
||||||
func (p *PasskeyLogin) RenderButtonTemplate(ctx context.Context, req *http.Request) template.HTML {
|
func (p *PasskeyLogin) RenderButtonTemplate(ctx authContext.TemplateContext) {
|
||||||
return "<div>Passkey Button</div>"
|
// provide something non-nil
|
||||||
|
ctx.Render(struct{}{})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user