ran cargo fmt --all
This commit is contained in:
parent
2421d49d9a
commit
89a68741d6
|
@ -649,13 +649,13 @@ fn accept_invite(_org_id: String, _org_user_id: String, data: JsonUpcase<AcceptD
|
||||||
let user_twofactor_disabled = TwoFactor::find_by_user(&user_org.user_uuid, &conn).is_empty();
|
let user_twofactor_disabled = TwoFactor::find_by_user(&user_org.user_uuid, &conn).is_empty();
|
||||||
|
|
||||||
let policy = OrgPolicyType::TwoFactorAuthentication as i32;
|
let policy = OrgPolicyType::TwoFactorAuthentication as i32;
|
||||||
let org_twofactor_policy_enabled = match OrgPolicy::find_by_org_and_type(&user_org.org_uuid, policy, &conn) {
|
let org_twofactor_policy_enabled =
|
||||||
Some(p) => p.enabled,
|
match OrgPolicy::find_by_org_and_type(&user_org.org_uuid, policy, &conn) {
|
||||||
None => false,
|
Some(p) => p.enabled,
|
||||||
};
|
None => false,
|
||||||
|
};
|
||||||
|
|
||||||
if org_twofactor_policy_enabled && user_twofactor_disabled {
|
if org_twofactor_policy_enabled && user_twofactor_disabled {
|
||||||
|
|
||||||
err!("You cannot join this organization until you enable two-step login on your user account.")
|
err!("You cannot join this organization until you enable two-step login on your user account.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,16 +1010,14 @@ fn put_policy(
|
||||||
Some(pt) => pt,
|
Some(pt) => pt,
|
||||||
None => err!("Invalid policy type"),
|
None => err!("Invalid policy type"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if pol_type_enum == OrgPolicyType::TwoFactorAuthentication && data.enabled {
|
|
||||||
|
|
||||||
|
if pol_type_enum == OrgPolicyType::TwoFactorAuthentication && data.enabled {
|
||||||
let org_list = UserOrganization::find_by_org(&org_id, &conn);
|
let org_list = UserOrganization::find_by_org(&org_id, &conn);
|
||||||
|
|
||||||
for user_org in org_list.into_iter() {
|
for user_org in org_list.into_iter() {
|
||||||
let user_twofactor_disabled = TwoFactor::find_by_user(&user_org.user_uuid, &conn).is_empty();
|
let user_twofactor_disabled = TwoFactor::find_by_user(&user_org.user_uuid, &conn).is_empty();
|
||||||
|
|
||||||
if user_twofactor_disabled && user_org.atype < UserOrgType::Admin {
|
if user_twofactor_disabled && user_org.atype < UserOrgType::Admin {
|
||||||
|
|
||||||
if CONFIG.mail_enabled() {
|
if CONFIG.mail_enabled() {
|
||||||
let org = Organization::find_by_uuid(&user_org.org_uuid, &conn).unwrap();
|
let org = Organization::find_by_uuid(&user_org.org_uuid, &conn).unwrap();
|
||||||
let user = User::find_by_uuid(&user_org.user_uuid, &conn).unwrap();
|
let user = User::find_by_uuid(&user_org.user_uuid, &conn).unwrap();
|
||||||
|
@ -1028,7 +1026,7 @@ fn put_policy(
|
||||||
}
|
}
|
||||||
user_org.delete(&conn)?;
|
user_org.delete(&conn)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut policy = match OrgPolicy::find_by_org_and_type(&org_id, pol_type, &conn) {
|
let mut policy = match OrgPolicy::find_by_org_and_type(&org_id, pol_type, &conn) {
|
||||||
|
|
|
@ -7,10 +7,7 @@ use crate::{
|
||||||
api::{JsonResult, JsonUpcase, NumberOrString, PasswordData},
|
api::{JsonResult, JsonUpcase, NumberOrString, PasswordData},
|
||||||
auth::Headers,
|
auth::Headers,
|
||||||
crypto,
|
crypto,
|
||||||
db::{
|
db::{models::*, DbConn},
|
||||||
models::*,
|
|
||||||
DbConn,
|
|
||||||
},
|
|
||||||
mail, CONFIG,
|
mail, CONFIG,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,9 +133,7 @@ fn disable_twofactor(data: JsonUpcase<DisableTwoFactorData>, headers: Headers, c
|
||||||
let org_list = UserOrganization::find_by_user_and_policy(&user.uuid, policy_type, &conn);
|
let org_list = UserOrganization::find_by_user_and_policy(&user.uuid, policy_type, &conn);
|
||||||
|
|
||||||
for user_org in org_list.into_iter() {
|
for user_org in org_list.into_iter() {
|
||||||
|
|
||||||
if user_org.atype < UserOrgType::Admin {
|
if user_org.atype < UserOrgType::Admin {
|
||||||
|
|
||||||
if CONFIG.mail_enabled() {
|
if CONFIG.mail_enabled() {
|
||||||
let org = Organization::find_by_uuid(&user_org.org_uuid, &conn).unwrap();
|
let org = Organization::find_by_uuid(&user_org.org_uuid, &conn).unwrap();
|
||||||
mail::send_2fa_removed_from_org(&user.email, &org.name)?;
|
mail::send_2fa_removed_from_org(&user.email, &org.name)?;
|
||||||
|
|
|
@ -181,11 +181,7 @@ pub fn send_welcome_must_verify(address: &str, uuid: &str) -> EmptyResult {
|
||||||
send_email(address, &subject, body_html, body_text)
|
send_email(address, &subject, body_html, body_text)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_2fa_removed_from_org(
|
pub fn send_2fa_removed_from_org(address: &str, org_name: &str) -> EmptyResult {
|
||||||
address: &str,
|
|
||||||
org_name: &str,
|
|
||||||
) -> EmptyResult {
|
|
||||||
|
|
||||||
let (subject, body_html, body_text) = get_text(
|
let (subject, body_html, body_text) = get_text(
|
||||||
"email/send_2fa_removed_from_org",
|
"email/send_2fa_removed_from_org",
|
||||||
json!({
|
json!({
|
||||||
|
|
Loading…
Reference in New Issue