You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
Make password-based login optional
This commit is contained in:
@ -286,6 +286,7 @@ pub struct PostAuthContext {
|
||||
pub struct LoginContext {
|
||||
form: FormState<LoginFormField>,
|
||||
next: Option<PostAuthContext>,
|
||||
password_disabled: bool,
|
||||
providers: Vec<UpstreamOAuthProvider>,
|
||||
}
|
||||
|
||||
@ -295,15 +296,33 @@ impl TemplateContext for LoginContext {
|
||||
Self: Sized,
|
||||
{
|
||||
// TODO: samples with errors
|
||||
vec![LoginContext {
|
||||
form: FormState::default(),
|
||||
next: None,
|
||||
providers: Vec::new(),
|
||||
}]
|
||||
vec![
|
||||
LoginContext {
|
||||
form: FormState::default(),
|
||||
next: None,
|
||||
password_disabled: true,
|
||||
providers: Vec::new(),
|
||||
},
|
||||
LoginContext {
|
||||
form: FormState::default(),
|
||||
next: None,
|
||||
password_disabled: false,
|
||||
providers: Vec::new(),
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl LoginContext {
|
||||
/// Set whether password login is enabled or not
|
||||
#[must_use]
|
||||
pub fn with_password_login(self, enabled: bool) -> Self {
|
||||
Self {
|
||||
password_disabled: !enabled,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the form state
|
||||
#[must_use]
|
||||
pub fn with_form_state(self, form: FormState<LoginFormField>) -> Self {
|
||||
@ -312,7 +331,7 @@ impl LoginContext {
|
||||
|
||||
/// Set the upstream OAuth 2.0 providers
|
||||
#[must_use]
|
||||
pub fn with_upstrem_providers(self, providers: Vec<UpstreamOAuthProvider>) -> Self {
|
||||
pub fn with_upstream_providers(self, providers: Vec<UpstreamOAuthProvider>) -> Self {
|
||||
Self { providers, ..self }
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ use camino::{Utf8Path, Utf8PathBuf};
|
||||
use mas_router::UrlBuilder;
|
||||
use rand::Rng;
|
||||
use serde::Serialize;
|
||||
pub use tera::escape_html;
|
||||
use tera::{Context, Error as TeraError, Tera};
|
||||
use thiserror::Error;
|
||||
use tokio::{sync::RwLock, task::JoinError};
|
||||
|
Reference in New Issue
Block a user