mirror of
https://github.com/1f349/lavender.git
synced 2025-02-23 14:15:08 +00:00
Remove testAuthSources
This commit is contained in:
parent
363439e69b
commit
02f4443fb0
@ -46,25 +46,6 @@ func getUserLoginName(req *http.Request) string {
|
|||||||
return originUrl.Query().Get("login_name")
|
return originUrl.Query().Get("login_name")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpServer) testAuthSources(req *http.Request, user *database.User, factor auth.State) map[string]bool {
|
|
||||||
authSource := make(map[string]bool)
|
|
||||||
data := make(map[string]any)
|
|
||||||
for _, i := range h.authSources {
|
|
||||||
// ignore not-supported factors
|
|
||||||
if i.AccessState() != factor {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
form, ok := i.(auth.Form)
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
err := form.RenderTemplate(authContext.NewTemplateContext(req, user))
|
|
||||||
authSource[i.Name()] = err == nil
|
|
||||||
clear(data)
|
|
||||||
}
|
|
||||||
return authSource
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *httpServer) getAuthWithState(state auth.State) auth.Provider {
|
func (h *httpServer) getAuthWithState(state auth.State) auth.Provider {
|
||||||
for _, i := range h.authSources {
|
for _, i := range h.authSources {
|
||||||
if i.AccessState() == state {
|
if i.AccessState() == state {
|
||||||
@ -111,14 +92,11 @@ func (h *httpServer) loginGet(rw http.ResponseWriter, req *http.Request, _ httpr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%#v\n", h.testAuthSources(req, userPtr, auth.StateBasic))
|
|
||||||
|
|
||||||
web.RenderPageTemplate(rw, "login-memory", map[string]any{
|
web.RenderPageTemplate(rw, "login-memory", map[string]any{
|
||||||
"ServiceName": h.conf.ServiceName,
|
"ServiceName": h.conf.ServiceName,
|
||||||
"LoginName": cookie.Value,
|
"LoginName": cookie.Value,
|
||||||
"Redirect": req.URL.Query().Get("redirect"),
|
"Redirect": req.URL.Query().Get("redirect"),
|
||||||
"Source": "start",
|
"Source": "start",
|
||||||
"Auth": h.testAuthSources(req, userPtr, auth.StateBasic),
|
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user