Check login before logging it

This commit is contained in:
2024-02-19 19:11:13 +01:00
parent 75b70008e3
commit e71fad8546
7 changed files with 71 additions and 5 deletions

View File

@ -18,6 +18,7 @@ use crate::data::provider::{Provider, ProvidersManager};
use crate::data::session_identity::{SessionIdentity, SessionStatus};
use crate::data::user::User;
use crate::data::webauthn_manager::WebAuthManagerReq;
use crate::utils::string_utils;
pub struct BaseLoginPage<'a> {
pub danger: Option<String>,
@ -132,6 +133,16 @@ pub async fn login_route(
query.redirect.get_encoded()
));
}
// Check if given login is not acceptable
else if req
.as_ref()
.map(|r| string_utils::is_acceptable_login(&r.login))
== Some(false)
{
danger = Some(
"Given login could not be processed, because it has an invalid format!".to_string(),
);
}
// Try to authenticate user
else if let Some(req) = &req {
login = req.login.clone();