Skip to content

Commit

Permalink
allow registration without invite link
Browse files Browse the repository at this point in the history
if signups are allowed invited users should be able to complete their
registration even when they don't have the invite link at hand.
  • Loading branch information
stefan0xC committed Oct 18, 2022
1 parent 638766b commit aa5a059
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/api/core/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ async fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> JsonResult {
let mut user = match User::find_by_mail(&email, &conn).await {
Some(user) => {
if !user.password_hash.is_empty() {
if CONFIG.is_signup_allowed(&email) {
err!("User already exists")
} else {
err!("Registration not allowed or user already exists")
}
err!("Registration not allowed or user already exists")
}

if let Some(token) = data.Token {
Expand All @@ -121,10 +117,10 @@ async fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> JsonResult {
user_org.save(&conn).await?;
}
user
} else if EmergencyAccess::find_invited_by_grantee_email(&email, &conn).await.is_some() {
} else if CONFIG.is_signup_allowed(&email)
|| EmergencyAccess::find_invited_by_grantee_email(&email, &conn).await.is_some()
{
user
} else if CONFIG.is_signup_allowed(&email) {
err!("Account with this email already exists")
} else {
err!("Registration not allowed or user already exists")
}
Expand Down

0 comments on commit aa5a059

Please sign in to comment.