1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

refactor getOrgPolicies call

This commit is contained in:
rr-bw
2024-08-27 16:21:08 -07:00
parent 688a24bd52
commit 97f9008b60
13 changed files with 49 additions and 68 deletions

View File

@@ -1,7 +1,5 @@
import { UrlTree } from "@angular/router";
import { OrganizationInvite } from "@bitwarden/auth/common";
import { LoginService, PasswordPolicies } from "./login.service";
export class DefaultLoginService implements LoginService {
@@ -9,11 +7,7 @@ export class DefaultLoginService implements LoginService {
return null;
}
async getOrganizationInvite(): Promise<OrganizationInvite | null> {
return null;
}
async getPasswordPolicies(invite: OrganizationInvite): Promise<PasswordPolicies | null> {
async getOrgPolicies(): Promise<PasswordPolicies | null> {
return null;
}
}

View File

@@ -6,12 +6,9 @@ import { first, firstValueFrom, Subject, takeUntil } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { LoginEmailServiceAbstraction } from "@bitwarden/auth/common";
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
import { InternalPolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
import { ClientType } from "@bitwarden/common/enums";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import {
AsyncActionsModule,
@@ -56,10 +53,7 @@ export class LoginComponentV2 implements OnInit {
private formBuilder: FormBuilder,
private loginEmailService: LoginEmailServiceAbstraction,
private loginService: LoginService,
private logService: LogService,
private platformUtilsService: PlatformUtilsService,
private policyApiService: PolicyApiServiceAbstraction,
private policyService: InternalPolicyService,
private router: Router,
) {
this.clientType = this.platformUtilsService.getClientType();
@@ -93,15 +87,12 @@ export class LoginComponentV2 implements OnInit {
if (this.clientType === ClientType.Web) {
// If there's an existing org invite, use it to get the password policies
const orgInvite = await this.loginService.getOrganizationInvite();
if (orgInvite != null) {
const { policies, isPolicyAndAutoEnrollEnabled, enforcedPasswordPolicyOptions } =
await this.loginService.getPasswordPolicies(orgInvite);
const { policies, isPolicyAndAutoEnrollEnabled, enforcedPasswordPolicyOptions } =
await this.loginService.getOrgPolicies();
this.policies = policies;
this.showResetPasswordAutoEnrollWarning = isPolicyAndAutoEnrollEnabled;
this.enforcedPasswordPolicyOptions = enforcedPasswordPolicyOptions;
}
this.policies = policies;
this.showResetPasswordAutoEnrollWarning = isPolicyAndAutoEnrollEnabled;
this.enforcedPasswordPolicyOptions = enforcedPasswordPolicyOptions;
}
}

View File

@@ -1,6 +1,5 @@
import { UrlTree } from "@angular/router";
import { OrganizationInvite } from "@bitwarden/auth/common";
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
@@ -12,7 +11,6 @@ export interface PasswordPolicies {
export abstract class LoginService {
// Web specific
getOrganizationInvite: () => Promise<OrganizationInvite | null>;
getPasswordPolicies: (invite: OrganizationInvite) => Promise<PasswordPolicies | null>;
getOrgPolicies: () => Promise<PasswordPolicies | null>;
setPreviousUrl: (route: UrlTree) => void | null;
}