mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
Move policy checks inside PolicyService (#1533)
* Move policy checks inside PolicyService * Remove leftover code * Remove duplicate code * Reorder code for consistency
This commit is contained in:
@@ -309,7 +309,6 @@ namespace Bit.App.Pages
|
||||
|
||||
public async Task<bool> LoadAsync(AppOptions appOptions = null)
|
||||
{
|
||||
var policies = (await _policyService.GetAll(PolicyType.PersonalOwnership))?.ToList();
|
||||
var myEmail = await _userService.GetEmailAsync();
|
||||
OwnershipOptions.Add(new KeyValuePair<string, string>(myEmail, null));
|
||||
var orgs = await _userService.GetAllOrganizationAsync();
|
||||
@@ -318,28 +317,17 @@ namespace Bit.App.Pages
|
||||
if (org.Enabled && org.Status == OrganizationUserStatusType.Confirmed)
|
||||
{
|
||||
OwnershipOptions.Add(new KeyValuePair<string, string>(org.Name, org.Id));
|
||||
if ((!EditMode || CloneMode) && policies != null && org.UsePolicies && !org.canManagePolicies &&
|
||||
AllowPersonal)
|
||||
{
|
||||
foreach (var policy in policies)
|
||||
{
|
||||
if (policy.OrganizationId == org.Id && policy.Enabled)
|
||||
{
|
||||
AllowPersonal = false;
|
||||
// Remove personal ownership
|
||||
OwnershipOptions.RemoveAt(0);
|
||||
// Default to the organization who owns this policy for now (if necessary)
|
||||
if (string.IsNullOrWhiteSpace(OrganizationId))
|
||||
{
|
||||
OrganizationId = org.Id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var personalOwnershipPolicyApplies = await _policyService.PolicyAppliesToUser(PolicyType.PersonalOwnership);
|
||||
if (personalOwnershipPolicyApplies && (!EditMode || CloneMode))
|
||||
{
|
||||
AllowPersonal = false;
|
||||
// Remove personal ownership
|
||||
OwnershipOptions.RemoveAt(0);
|
||||
}
|
||||
|
||||
var allCollections = await _collectionService.GetAllDecryptedAsync();
|
||||
_writeableCollections = allCollections.Where(c => !c.ReadOnly).ToList();
|
||||
if (CollectionIds?.Any() ?? false)
|
||||
|
||||
Reference in New Issue
Block a user