You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-09 04:22:45 +03:00
Gate account recovery behing a configuration flag
This commit is contained in:
@@ -54,6 +54,7 @@ impl SiteConfigExt for SiteConfig {
|
||||
SiteFeatures {
|
||||
password_registration: self.password_registration_enabled,
|
||||
password_login: self.password_login_enabled,
|
||||
account_recovery: self.account_recovery_allowed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,9 @@ pub struct SiteFeatures {
|
||||
|
||||
/// Whether local password-based login is enabled.
|
||||
pub password_login: bool,
|
||||
|
||||
/// Whether email-based account recovery is enabled.
|
||||
pub account_recovery: bool,
|
||||
}
|
||||
|
||||
impl Object for SiteFeatures {
|
||||
@@ -34,11 +37,16 @@ impl Object for SiteFeatures {
|
||||
match field.as_str()? {
|
||||
"password_registration" => Some(Value::from(self.password_registration)),
|
||||
"password_login" => Some(Value::from(self.password_login)),
|
||||
"account_recovery" => Some(Value::from(self.account_recovery)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn enumerate(self: &Arc<Self>) -> Enumerator {
|
||||
Enumerator::Str(&["password_registration", "password_login"])
|
||||
Enumerator::Str(&[
|
||||
"password_registration",
|
||||
"password_login",
|
||||
"account_recovery",
|
||||
])
|
||||
}
|
||||
}
|
||||
|
@@ -357,6 +357,9 @@ register_templates! {
|
||||
/// Render the account recovery finish page
|
||||
pub fn render_recovery_finish(WithLanguage<WithCsrf<RecoveryFinishContext>>) { "pages/recovery/finish.html" }
|
||||
|
||||
/// Render the account recovery disabled page
|
||||
pub fn render_recovery_disabled(WithLanguage<EmptyContext>) { "pages/recovery/disabled.html" }
|
||||
|
||||
/// Render the re-authentication form
|
||||
pub fn render_reauth(WithLanguage<WithCsrf<WithSession<ReauthContext>>>) { "pages/reauth.html" }
|
||||
|
||||
@@ -425,6 +428,7 @@ impl Templates {
|
||||
check::render_recovery_start(self, now, rng)?;
|
||||
check::render_recovery_progress(self, now, rng)?;
|
||||
check::render_recovery_finish(self, now, rng)?;
|
||||
check::render_recovery_disabled(self, now, rng)?;
|
||||
check::render_reauth(self, now, rng)?;
|
||||
check::render_form_post::<EmptyContext>(self, now, rng)?;
|
||||
check::render_error(self, now, rng)?;
|
||||
@@ -455,6 +459,7 @@ mod tests {
|
||||
let features = SiteFeatures {
|
||||
password_login: true,
|
||||
password_registration: true,
|
||||
account_recovery: true,
|
||||
};
|
||||
let vite_manifest_path =
|
||||
Utf8Path::new(env!("CARGO_MANIFEST_DIR")).join("../../frontend/dist/manifest.json");
|
||||
|
Reference in New Issue
Block a user