1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-09-09 11:12:42 +00:00

Merge branch 'master' of github.com:dani-garcia/bitwarden_rs into 2fa_enforcement

# Conflicts:
#	src/db/models/org_policy.rs
#	src/db/models/organization.rs
This commit is contained in:
Olivier Martin 2021-04-16 14:29:28 -04:00
commit 2421d49d9a
43 changed files with 592 additions and 617 deletions

View file

@ -4,7 +4,7 @@ use crate::api::EmptyResult;
use crate::db::DbConn;
use crate::error::MapResult;
use super::{Organization, UserOrganization, UserOrgStatus, UserOrgType};
use super::{Organization, UserOrgStatus, UserOrgType, UserOrganization};
db_object! {
#[derive(Identifiable, Queryable, Insertable, Associations, AsChangeset)]
@ -20,9 +20,7 @@ db_object! {
}
}
#[derive(Copy, Clone)]
#[derive(num_derive::FromPrimitive)]
#[derive(PartialEq)]
#[derive(Copy, Clone, PartialEq, num_derive::FromPrimitive)]
pub enum OrgPolicyType {
TwoFactorAuthentication = 0,
MasterPassword = 1,
@ -176,7 +174,8 @@ impl OrgPolicy {
/// and the user is not an owner or admin of that org. This is only useful for checking
/// applicability of policy types that have these particular semantics.
pub fn is_applicable_to_user(user_uuid: &str, policy_type: OrgPolicyType, conn: &DbConn) -> bool {
for policy in OrgPolicy::find_by_user(user_uuid, conn) { // Returns confirmed users only.
// Returns confirmed users only.
for policy in OrgPolicy::find_by_user(user_uuid, conn) {
if policy.enabled && policy.has_type(policy_type) {
let org_uuid = &policy.org_uuid;
if let Some(user) = UserOrganization::find_by_user_and_org(user_uuid, org_uuid, conn) {