mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 17:33: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 (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RecaptchaTemplate is template for recaptcha auth
|
// RecaptchaTemplate is template for recaptcha auth
|
||||||
|
|
@ -87,14 +89,18 @@ if (window.onAuthDone) {
|
||||||
`
|
`
|
||||||
|
|
||||||
// AuthFallback implements GET on /auth/{authType}/fallback/web?session={sessionID}
|
// 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" {
|
if req.Method == "GET" {
|
||||||
t := template.Must(template.New("response").Parse(RECAPTCHA_TEMPLATE))
|
t := template.Must(template.New("response").Parse(RECAPTCHA_TEMPLATE))
|
||||||
|
|
||||||
data := map[string]string{
|
data := map[string]string{
|
||||||
"MyUrl": "TODO",
|
"MyUrl": req.URL.String(),
|
||||||
"Session": "TODO",
|
"Session": sessionID,
|
||||||
"SiteKey": "TODO",
|
"SiteKey": cfg.Matrix.RecaptchaPublicKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := t.Execute(w, data); err != nil {
|
if err := t.Execute(w, data); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ func Setup(
|
||||||
r0mux.Handle("/auth/{authType}/fallback/web?session={sessionID}",
|
r0mux.Handle("/auth/{authType}/fallback/web?session={sessionID}",
|
||||||
common.MakeHtmlAPI("authfallback", func(w http.ResponseWriter, req *http.Request) util.JSONResponse {
|
common.MakeHtmlAPI("authfallback", func(w http.ResponseWriter, req *http.Request) util.JSONResponse {
|
||||||
vars := mux.Vars(req)
|
vars := mux.Vars(req)
|
||||||
return AuthFallback(w, req, vars["authType"], vars["sessionID"])
|
return AuthFallback(w, req, vars["authType"], vars["sessionID"], cfg)
|
||||||
}),
|
}),
|
||||||
).Methods("GET", "OPTIONS")
|
).Methods("GET", "OPTIONS")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue