|
|
@ -101,12 +101,8 @@ async fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> JsonResult {
|
|
|
|
let mut user = match User::find_by_mail(&email, &conn).await {
|
|
|
|
let mut user = match User::find_by_mail(&email, &conn).await {
|
|
|
|
Some(user) => {
|
|
|
|
Some(user) => {
|
|
|
|
if !user.password_hash.is_empty() {
|
|
|
|
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 {
|
|
|
|
if let Some(token) = data.Token {
|
|
|
|
let claims = decode_invite(&token)?;
|
|
|
|
let claims = decode_invite(&token)?;
|
|
|
@ -121,10 +117,10 @@ async fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> JsonResult {
|
|
|
|
user_org.save(&conn).await?;
|
|
|
|
user_org.save(&conn).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
user
|
|
|
|
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
|
|
|
|
user
|
|
|
|
} else if CONFIG.is_signup_allowed(&email) {
|
|
|
|
|
|
|
|
err!("Account with this email already exists")
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
err!("Registration not allowed or user already exists")
|
|
|
|
err!("Registration not allowed or user already exists")
|
|
|
|
}
|
|
|
|
}
|
|
|
|