Added the config to fallback handler

This commit is contained in:
Parminder Singh 2018-03-02 20:53:01 +05:30
parent 6fe226e0cc
commit e6e81e526d
2 changed files with 11 additions and 5 deletions

View file

@ -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 {

View file

@ -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")