More verbose
This commit is contained in:
parent
48ea920541
commit
877a485974
|
@ -39,6 +39,7 @@ import (
|
||||||
"github.com/matrix-org/gomatrixserverlib/tokens"
|
"github.com/matrix-org/gomatrixserverlib/tokens"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth"
|
"github.com/matrix-org/dendrite/clientapi/auth"
|
||||||
|
@ -551,9 +552,13 @@ func Register(
|
||||||
}
|
}
|
||||||
|
|
||||||
var r registerRequest
|
var r registerRequest
|
||||||
if v := cfg.Matrix.VirtualHostForHTTPHost(gomatrixserverlib.ServerName(req.Header.Get("Host"))); v != nil {
|
host := gomatrixserverlib.ServerName(req.Header.Get("Host"))
|
||||||
|
logrus.Infof("Getting virtual host for %q", host)
|
||||||
|
if v := cfg.Matrix.VirtualHostForHTTPHost(host); v != nil {
|
||||||
r.ServerName = v.ServerName
|
r.ServerName = v.ServerName
|
||||||
|
logrus.Infof("Found virtual host %q", host)
|
||||||
} else {
|
} else {
|
||||||
|
logrus.Infof("Using default %q", cfg.Matrix.ServerName)
|
||||||
r.ServerName = cfg.Matrix.ServerName
|
r.ServerName = cfg.Matrix.ServerName
|
||||||
}
|
}
|
||||||
sessionID := gjson.GetBytes(reqBody, "auth.session").String()
|
sessionID := gjson.GetBytes(reqBody, "auth.session").String()
|
||||||
|
@ -656,14 +661,16 @@ func handleGuestRegistration(
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
registrationEnabled := !cfg.RegistrationDisabled
|
registrationEnabled := !cfg.RegistrationDisabled
|
||||||
guestsEnabled := !cfg.GuestsDisabled
|
guestsEnabled := !cfg.GuestsDisabled
|
||||||
if r.ServerName != cfg.Matrix.ServerName {
|
if v := cfg.Matrix.VirtualHost(r.ServerName); v != nil {
|
||||||
registrationEnabled, guestsEnabled = cfg.Matrix.VirtualHost(r.ServerName).RegistrationAllowed()
|
registrationEnabled, guestsEnabled = v.RegistrationAllowed()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !registrationEnabled || !guestsEnabled {
|
if !registrationEnabled || !guestsEnabled {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
Code: http.StatusForbidden,
|
||||||
JSON: jsonerror.Forbidden("Guest registration is disabled"),
|
JSON: jsonerror.Forbidden(
|
||||||
|
fmt.Sprintf("Guest registration is disabled on %q", r.ServerName),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,13 +755,15 @@ func handleRegistrationFlow(
|
||||||
}
|
}
|
||||||
|
|
||||||
registrationEnabled := !cfg.RegistrationDisabled
|
registrationEnabled := !cfg.RegistrationDisabled
|
||||||
if r.ServerName != cfg.Matrix.ServerName {
|
if v := cfg.Matrix.VirtualHost(r.ServerName); v != nil {
|
||||||
registrationEnabled, _ = cfg.Matrix.VirtualHost(r.ServerName).RegistrationAllowed()
|
registrationEnabled, _ = v.RegistrationAllowed()
|
||||||
}
|
}
|
||||||
if !registrationEnabled && r.Auth.Type != authtypes.LoginTypeSharedSecret {
|
if !registrationEnabled && r.Auth.Type != authtypes.LoginTypeSharedSecret {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
Code: http.StatusForbidden,
|
||||||
JSON: jsonerror.Forbidden("Registration is disabled"),
|
JSON: jsonerror.Forbidden(
|
||||||
|
fmt.Sprintf("Registration is disabled on %q", r.ServerName),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue