mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
fill out webOnInit
This commit is contained in:
@@ -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 () => {};
|
||||
|
||||
Reference in New Issue
Block a user