Can disable local login
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -49,6 +49,7 @@ impl Default for BaseLoginPage {
|
||||
struct LoginTemplate {
|
||||
p: BaseLoginPage,
|
||||
login: String,
|
||||
show_local_login: bool,
|
||||
providers: Vec<Provider>,
|
||||
}
|
||||
|
||||
@@ -156,8 +157,10 @@ pub async fn login_route(
|
||||
"Given login could not be processed, because it has an invalid format!".to_string(),
|
||||
);
|
||||
}
|
||||
// Try to authenticate user
|
||||
else if let Some(req) = &req {
|
||||
// Try to authenticate user (local login)
|
||||
else if let Some(req) = &req
|
||||
&& !AppConfig::get().disable_local_login
|
||||
{
|
||||
login.clone_from(&req.login);
|
||||
let response: LoginResult = users
|
||||
.send(users_actor::LocalLoginRequest {
|
||||
@@ -224,6 +227,10 @@ pub async fn login_route(
|
||||
}
|
||||
}
|
||||
}
|
||||
// If there is only a single provider, trigger auto-login
|
||||
else if AppConfig::get().disable_local_login && providers.len() == 1 {
|
||||
return redirect_user(&providers.cloned()[0].login_url(&query.redirect));
|
||||
}
|
||||
|
||||
HttpResponse::Ok().content_type("text/html").body(
|
||||
LoginTemplate {
|
||||
@@ -235,6 +242,7 @@ pub async fn login_route(
|
||||
..Default::default()
|
||||
},
|
||||
login,
|
||||
show_local_login: !AppConfig::get().disable_local_login,
|
||||
providers: providers.cloned(),
|
||||
}
|
||||
.render()
|
||||
|
||||
Reference in New Issue
Block a user