mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 09:23:09 -06:00
Added the config to fallback handler
This commit is contained in:
parent
6fe226e0cc
commit
e6e81e526d
|
|
@ -17,6 +17,8 @@ package routing
|
|||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/common/config"
|
||||
)
|
||||
|
||||
// RecaptchaTemplate is template for recaptcha auth
|
||||
|
|
@ -87,14 +89,18 @@ if (window.onAuthDone) {
|
|||
`
|
||||
|
||||
// AuthFallback implements GET on /auth/{authType}/fallback/web?session={sessionID}
|
||||
func AuthFallback(w http.ResponseWriter, req *http.Request, authType string, sessionID string) {
|
||||
// TODO: Handle POST requests too
|
||||
func AuthFallback(
|
||||
w http.ResponseWriter, req *http.Request, authType string, sessionID string,
|
||||
cfg config.Dendrite,
|
||||
) {
|
||||
if req.Method == "GET" {
|
||||
t := template.Must(template.New("response").Parse(RECAPTCHA_TEMPLATE))
|
||||
|
||||
data := map[string]string{
|
||||
"MyUrl": "TODO",
|
||||
"Session": "TODO",
|
||||
"SiteKey": "TODO",
|
||||
"MyUrl": req.URL.String(),
|
||||
"Session": sessionID,
|
||||
"SiteKey": cfg.Matrix.RecaptchaPublicKey,
|
||||
}
|
||||
|
||||
if err := t.Execute(w, data); err != nil {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ func Setup(
|
|||
r0mux.Handle("/auth/{authType}/fallback/web?session={sessionID}",
|
||||
common.MakeHtmlAPI("authfallback", func(w http.ResponseWriter, req *http.Request) util.JSONResponse {
|
||||
vars := mux.Vars(req)
|
||||
return AuthFallback(w, req, vars["authType"], vars["sessionID"])
|
||||
return AuthFallback(w, req, vars["authType"], vars["sessionID"], cfg)
|
||||
}),
|
||||
).Methods("GET", "OPTIONS")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue