feat: close registration with ROCKET_REGISTRATION_DISABLED=true

This commit is contained in:
timokoesters 2020-06-06 19:02:31 +02:00
parent c85d363d71
commit 0067f49d52
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
3 changed files with 27 additions and 13 deletions

View file

@ -117,6 +117,14 @@ pub fn register_route(
db: State<'_, Database>,
body: Ruma<register::Request>,
) -> MatrixResult<register::Response, UiaaResponse> {
if db.globals.registration_disabled() {
return MatrixResult(Err(UiaaResponse::MatrixError(Error {
kind: ErrorKind::Unknown,
message: "Registration has been disabled.".to_owned(),
status_code: http::StatusCode::FORBIDDEN,
})));
}
// Validate user id
let user_id = match UserId::parse_with_server_name(
body.username