|
|
@ -220,6 +220,24 @@ async fn sso_login( |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
Some((user, None)) |
|
|
|
|
|
if user.private_key.is_none() |
|
|
|
|
|
&& !CONFIG.sso_signups_allowed() |
|
|
|
|
|
&& !CONFIG.is_email_domain_allowed(&user.email) |
|
|
|
|
|
&& !CONFIG.mail_enabled() |
|
|
|
|
|
&& Invitation::find_by_mail(&user.email, conn).await.is_none() => |
|
|
|
|
|
{ |
|
|
|
|
|
error!( |
|
|
|
|
|
"Login failure ({}), no invitation with email ({}) was found", |
|
|
|
|
|
user_infos.identifier, user.email |
|
|
|
|
|
); |
|
|
|
|
|
err_silent!( |
|
|
|
|
|
"Missing invitation", |
|
|
|
|
|
ErrorEvent { |
|
|
|
|
|
event: EventType::UserFailedLogIn |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
Some((user, None)) if user.private_key.is_some() && !CONFIG.sso_signups_match_email() => { |
|
|
Some((user, None)) if user.private_key.is_some() && !CONFIG.sso_signups_match_email() => { |
|
|
error!( |
|
|
error!( |
|
|
"Login failure ({}), existing non SSO user ({}) with same email ({}) and association is disabled", |
|
|
"Login failure ({}), existing non SSO user ({}) with same email ({}) and association is disabled", |
|
|
@ -267,13 +285,22 @@ async fn sso_login( |
|
|
// Will trigger 2FA flow if needed
|
|
|
// Will trigger 2FA flow if needed
|
|
|
let (user, mut device, twofactor_token, sso_user) = match user_with_sso { |
|
|
let (user, mut device, twofactor_token, sso_user) = match user_with_sso { |
|
|
None => { |
|
|
None => { |
|
|
if !CONFIG.is_email_domain_allowed(&user_infos.email) { |
|
|
if !CONFIG.sso_signups_allowed() { |
|
|
err!( |
|
|
if CONFIG.signups_domains_whitelist().is_empty() { |
|
|
"Email domain not allowed", |
|
|
err!( |
|
|
ErrorEvent { |
|
|
"Signups are disabled. You will need an invitation", |
|
|
event: EventType::UserFailedLogIn |
|
|
ErrorEvent { |
|
|
} |
|
|
event: EventType::UserFailedLogIn |
|
|
); |
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} else if !CONFIG.is_email_domain_allowed(&user_infos.email) { |
|
|
|
|
|
err!( |
|
|
|
|
|
"Email domain not allowed", |
|
|
|
|
|
ErrorEvent { |
|
|
|
|
|
event: EventType::UserFailedLogIn |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
match user_infos.email_verified { |
|
|
match user_infos.email_verified { |
|
|
|