mirror of
https://github.com/1f349/lavender.git
synced 2025-02-22 21:55:09 +00:00
Start adding memory login provider
This commit is contained in:
parent
0df2cf6681
commit
3fbe905cb2
33
auth/providers/memory.go
Normal file
33
auth/providers/memory.go
Normal file
@ -0,0 +1,33 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"github.com/1f349/lavender/auth"
|
||||
"github.com/1f349/lavender/auth/authContext"
|
||||
"github.com/1f349/lavender/web"
|
||||
)
|
||||
|
||||
var _ auth.Provider = (*MemoryLogin)(nil)
|
||||
|
||||
type MemoryLogin struct{}
|
||||
|
||||
func (m *MemoryLogin) AccessState() auth.State { return auth.StateUnauthorized }
|
||||
|
||||
func (m *MemoryLogin) Name() string { return "memory" }
|
||||
|
||||
func (m *MemoryLogin) RenderTemplate(ctx authContext.TemplateContext) error {
|
||||
cookie, err := ctx.Request().Cookie("lavender-user-memory")
|
||||
if err == nil && cookie.Valid() == nil {
|
||||
ctx.Render(struct {
|
||||
ServiceName string
|
||||
LoginName string
|
||||
Redirect string
|
||||
}{
|
||||
ServiceName: ,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MemoryLogin) AttemptLogin(ctx authContext.TemplateContext) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
@ -91,6 +91,8 @@ func (h *httpServer) loginGet(rw http.ResponseWriter, req *http.Request, _ httpr
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: some of this should be more like tulip
|
||||
|
||||
cookie, err := req.Cookie("lavender-login-name")
|
||||
if err == nil && cookie.Valid() == nil {
|
||||
user, err := h.db.GetUser(req.Context(), userAuth.Subject)
|
||||
@ -158,6 +160,8 @@ func (h *httpServer) loginPost(rw http.ResponseWriter, req *http.Request, _ http
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: some of this should be more like tulip
|
||||
|
||||
if req.PostFormValue("not-you") == "1" {
|
||||
http.SetCookie(rw, &http.Cookie{
|
||||
Name: "lavender-login-name",
|
||||
|
Loading…
x
Reference in New Issue
Block a user