mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 10:43:35 +00:00
refactor getOrgPolicies call
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from "./organization-invite";
|
||||
export * from "./rotateable-key-set";
|
||||
export * from "./login-credentials";
|
||||
export * from "./user-decryption-options";
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import { Params } from "@angular/router";
|
||||
import { Jsonify } from "type-fest";
|
||||
|
||||
export class OrganizationInvite {
|
||||
email: string;
|
||||
initOrganization: boolean;
|
||||
orgSsoIdentifier: string;
|
||||
orgUserHasExistingUser: boolean;
|
||||
organizationId: string;
|
||||
organizationName: string;
|
||||
organizationUserId: string;
|
||||
token: string;
|
||||
|
||||
static fromJSON(json: Jsonify<OrganizationInvite>): OrganizationInvite | null {
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Object.assign(new OrganizationInvite(), json);
|
||||
}
|
||||
|
||||
static fromParams(params: Params): OrganizationInvite | null {
|
||||
if (params == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Object.assign(new OrganizationInvite(), {
|
||||
email: params.email,
|
||||
initOrganization: params.initOrganization?.toLocaleLowerCase() === "true",
|
||||
orgSsoIdentifier: params.orgSsoIdentifier,
|
||||
orgUserHasExistingUser: params.orgUserHasExistingUser?.toLocaleLowerCase() === "true",
|
||||
organizationId: params.organizationId,
|
||||
organizationName: params.organizationName,
|
||||
organizationUserId: params.organizationUserId,
|
||||
token: params.token,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user