1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

fill out webOnInit

This commit is contained in:
rr-bw
2024-08-27 09:31:17 -07:00
parent fcf01fee74
commit 688a24bd52
13 changed files with 109 additions and 20 deletions

View File

@@ -6,7 +6,12 @@ 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,
@@ -41,18 +46,26 @@ export class LoginComponentV2 implements OnInit {
private destroy$ = new Subject<void>();
// Web specific properties
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[];
showResetPasswordAutoEnrollWarning = false;
constructor(
private activatedRoute: ActivatedRoute,
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();
}
async ngOnInit(): Promise<void> {
this.clientType = this.platformUtilsService.getClientType();
if (this.clientType === ClientType.Web) {
await this.webOnInit();
}
@@ -66,17 +79,30 @@ export class LoginComponentV2 implements OnInit {
const qParamsEmail = params.email;
// If there is an email in the query params, set that email as the form field value
if (qParamsEmail?.indexOf("@") > -1) {
this.formGroup.controls.email.setValue(qParamsEmail);
paramEmailIsSet = true;
}
});
// If there is no email in the query params, attempt to load email settings from loginEmailService
if (!paramEmailIsSet) {
await this.loadEmailSettings();
}
// If there's an existing org invite, use it to get the password policies
await this.loginService.handleExistingOrgInvite();
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);
this.policies = policies;
this.showResetPasswordAutoEnrollWarning = isPolicyAndAutoEnrollEnabled;
this.enforcedPasswordPolicyOptions = enforcedPasswordPolicyOptions;
}
}
}
submit = async () => {};