 Stefan Melmuk
					
					1 year ago
						Stefan Melmuk
					
					1 year ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: B5690EEEBB952194
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
6 additions and 
4 deletions
			 
			
		 
		
			
				- 
					
					
					 
					src/api/core/accounts.rs
				
- 
					
					
					 
					src/db/models/org_policy.rs
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -112,7 +112,7 @@ async fn is_email_2fa_required(org_user_uuid: Option<String>, conn: &mut DbConn) | 
			
		
	
		
			
				
					|  |  |  |         return true; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |     if org_user_uuid.is_some() { | 
			
		
	
		
			
				
					|  |  |  |         return OrgPolicy::is_enabled_by_org(&org_user_uuid.unwrap(), OrgPolicyType::TwoFactorAuthentication, conn) | 
			
		
	
		
			
				
					|  |  |  |         return OrgPolicy::is_enabled_for_member(&org_user_uuid.unwrap(), OrgPolicyType::TwoFactorAuthentication, conn) | 
			
		
	
		
			
				
					|  |  |  |             .await; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |     false | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -342,10 +342,12 @@ impl OrgPolicy { | 
			
		
	
		
			
				
					|  |  |  |         false | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     pub async fn is_enabled_by_org(org_uuid: &str, policy_type: OrgPolicyType, conn: &mut DbConn) -> bool { | 
			
		
	
		
			
				
					|  |  |  |         if let Some(policy) = OrgPolicy::find_by_org_and_type(org_uuid, policy_type, conn).await { | 
			
		
	
		
			
				
					|  |  |  |     pub async fn is_enabled_for_member(org_user_uuid: &str, policy_type: OrgPolicyType, conn: &mut DbConn) -> bool { | 
			
		
	
		
			
				
					|  |  |  |         if let Some(membership) = UserOrganization::find_by_uuid(org_user_uuid, conn).await { | 
			
		
	
		
			
				
					|  |  |  |             if let Some(policy) = OrgPolicy::find_by_org_and_type(&membership.org_uuid, policy_type, conn).await { | 
			
		
	
		
			
				
					|  |  |  |                 return policy.enabled; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         false | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |