Timshel
2 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
12 additions and
7 deletions
-
src/api/core/organizations.rs
-
src/auth.rs
-
src/db/models/user.rs
|
|
@ -3038,7 +3038,8 @@ async fn recover_account( |
|
|
err!("Organization user must be confirmed for password reset functionality"); |
|
|
err!("Organization user must be confirmed for password reset functionality"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let fallback_2fa_email = if req.reset_two_factor && CONFIG.email_2fa_auto_fallback() { |
|
|
let fallback_2fa_email = |
|
|
|
|
|
if req.reset_two_factor && CONFIG.mail_enabled() && CONFIG.email_2fa_auto_fallback() && user.verified() { |
|
|
TwoFactor::find_by_user_and_type(&user.uuid, TwoFactorType::Email as i32, &conn).await.is_none() |
|
|
TwoFactor::find_by_user_and_type(&user.uuid, TwoFactorType::Email as i32, &conn).await.is_none() |
|
|
} else { |
|
|
} else { |
|
|
false |
|
|
false |
|
|
|
|
|
@ -253,7 +253,7 @@ impl LoginJwtClaims { |
|
|
premium: true, |
|
|
premium: true, |
|
|
name: user.name.clone(), |
|
|
name: user.name.clone(), |
|
|
email: user.email.clone(), |
|
|
email: user.email.clone(), |
|
|
email_verified: !CONFIG.mail_enabled() || user.verified_at.is_some(), |
|
|
email_verified: user.verified(), |
|
|
|
|
|
|
|
|
// ---
|
|
|
// ---
|
|
|
// Disabled these keys to be added to the JWT since they could cause the JWT to get too large
|
|
|
// Disabled these keys to be added to the JWT since they could cause the JWT to get too large
|
|
|
|
|
|
@ -257,6 +257,10 @@ impl User { |
|
|
|
|
|
|
|
|
/// Database methods
|
|
|
/// Database methods
|
|
|
impl User { |
|
|
impl User { |
|
|
|
|
|
pub fn verified(&self) -> bool { |
|
|
|
|
|
!CONFIG.mail_enabled() || self.verified_at.is_some() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
pub async fn to_json(&self, conn: &DbConn) -> Value { |
|
|
pub async fn to_json(&self, conn: &DbConn) -> Value { |
|
|
let mut orgs_json = Vec::new(); |
|
|
let mut orgs_json = Vec::new(); |
|
|
for c in Membership::find_confirmed_by_user(&self.uuid, conn).await { |
|
|
for c in Membership::find_confirmed_by_user(&self.uuid, conn).await { |
|
|
@ -299,7 +303,7 @@ impl User { |
|
|
"id": self.uuid, |
|
|
"id": self.uuid, |
|
|
"name": self.name, |
|
|
"name": self.name, |
|
|
"email": self.email, |
|
|
"email": self.email, |
|
|
"emailVerified": !CONFIG.mail_enabled() || self.verified_at.is_some(), |
|
|
"emailVerified": self.verified(), |
|
|
"premium": true, |
|
|
"premium": true, |
|
|
"premiumFromOrganization": false, |
|
|
"premiumFromOrganization": false, |
|
|
"culture": "en-US", |
|
|
"culture": "en-US", |
|
|
|