mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 17:33:09 -06:00
Handle unavailability of recaptcha key and session id
This commit is contained in:
parent
55552050c6
commit
a3ff68c2b1
|
|
@ -104,12 +104,18 @@ func AuthFallback(
|
|||
w http.ResponseWriter, req *http.Request, authType string,
|
||||
cfg config.Dendrite,
|
||||
) *util.JSONResponse {
|
||||
sessionID := req.Form.Get("session")
|
||||
sessionID := req.URL.Query().Get("session")
|
||||
|
||||
if sessionID == "" {
|
||||
w.Write([]byte("Session ID not provided"))
|
||||
return nil
|
||||
}
|
||||
|
||||
ServeRecaptcha := func() {
|
||||
data := map[string]string{
|
||||
"MyUrl": req.URL.String(),
|
||||
"Session": sessionID,
|
||||
"SiteKey": cfg.Matrix.RecaptchaPublicKey,
|
||||
"SiteKey": cfg.Matrix.RecaptchaPrivateKey,
|
||||
}
|
||||
ServeTemplate(w, RecaptchaTemplate, data)
|
||||
}
|
||||
|
|
@ -122,6 +128,11 @@ func AuthFallback(
|
|||
if req.Method == "GET" {
|
||||
// Handle Recaptcha
|
||||
if authType == authtypes.LoginTypeRecaptcha {
|
||||
if cfg.Matrix.RecaptchaPrivateKey == "" {
|
||||
w.Write([]byte("Homeserver doesn't have a recaptcha public key"))
|
||||
return nil
|
||||
}
|
||||
|
||||
ServeRecaptcha()
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue