1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 22:03:36 +00:00

[PM-4961]anon-layout login component migrated (#9167)

* anaon-layout login component migrated

* Login component migration

* Login component migration

---------

Co-authored-by: Ike Kottlowski <ikottlowski@bitwarden.com>
This commit is contained in:
vinith-kovan
2024-06-12 18:59:44 +05:30
committed by GitHub
parent d5e0ab74a4
commit ae688d9e9e
3 changed files with 127 additions and 138 deletions

View File

@@ -1,27 +1,14 @@
<form <form
#form [bitSubmit]="submitForm.bind(null, false)"
(ngSubmit)="submit(false)"
[appApiAction]="formPromise" [appApiAction]="formPromise"
class="tw-container tw-mx-auto"
[formGroup]="formGroup" [formGroup]="formGroup"
class="tw-w-96"
> >
<div
class="tw-mx-auto tw-mt-5 tw-flex tw-max-w-lg tw-flex-col tw-items-center tw-justify-center tw-p-8"
>
<div>
<img class="logo logo-themed" alt="Bitwarden" />
<p class="tw-mx-4 tw-mb-4 tw-mt-3 tw-text-center tw-text-xl">
{{ "loginOrCreateNewAccount" | i18n }}
</p>
<div
class="tw-mt-3 tw-rounded-md tw-border tw-border-solid tw-border-secondary-300 tw-bg-background tw-p-6"
>
<ng-container *ngIf="!validatedEmail"> <ng-container *ngIf="!validatedEmail">
<div class="tw-mb-3"> <div class="tw-mb-3">
<bit-form-field> <bit-form-field>
<bit-label>{{ "emailAddress" | i18n }}</bit-label> <bit-label>{{ "emailAddress" | i18n }}</bit-label>
<input <input
id="login_input_email"
bitInput bitInput
type="email" type="email"
formControlName="email" formControlName="email"
@@ -44,7 +31,6 @@
type="button" type="button"
buttonType="primary" buttonType="primary"
class="tw-w-full" class="tw-w-full"
[disabled]="form.loading"
(click)="validateEmail()" (click)="validateEmail()"
> >
<span> {{ "continue" | i18n }} </span> <span> {{ "continue" | i18n }} </span>
@@ -78,13 +64,7 @@
<div class="tw-mb-6 tw-h-28"> <div class="tw-mb-6 tw-h-28">
<bit-form-field class="!tw-mb-1"> <bit-form-field class="!tw-mb-1">
<bit-label>{{ "masterPass" | i18n }}</bit-label> <bit-label>{{ "masterPass" | i18n }}</bit-label>
<input <input type="password" bitInput #masterPasswordInput formControlName="masterPassword" />
id="login_input_master-password"
type="password"
bitInput
#masterPasswordInput
formControlName="masterPassword"
/>
<button type="button" bitSuffix bitIconButton bitPasswordInputToggle></button> <button type="button" bitSuffix bitIconButton bitPasswordInputToggle></button>
</bit-form-field> </bit-form-field>
<a <a
@@ -97,21 +77,11 @@
</div> </div>
<div [hidden]="!showCaptcha()"> <div [hidden]="!showCaptcha()">
<iframe <iframe id="hcaptcha_iframe" height="80" sandbox="allow-scripts allow-same-origin"></iframe>
id="hcaptcha_iframe"
height="80"
sandbox="allow-scripts allow-same-origin"
></iframe>
</div> </div>
<div class="tw-mb-3 tw-flex tw-space-x-4"> <div class="tw-mb-3 tw-flex tw-space-x-4">
<button <button bitButton buttonType="primary" bitFormButton type="submit" [block]="true">
bitButton
buttonType="primary"
type="submit"
[block]="true"
[loading]="form.loading"
>
<span> {{ "loginWithMasterPassword" | i18n }} </span> <span> {{ "loginWithMasterPassword" | i18n }} </span>
</button> </button>
</div> </div>
@@ -149,7 +119,4 @@
<a [routerLink]="[]" (click)="toggleValidateEmail(false)">{{ "notYou" | i18n }}</a> <a [routerLink]="[]" (click)="toggleValidateEmail(false)">{{ "notYou" | i18n }}</a>
</div> </div>
</div> </div>
</div>
</div>
</div>
</form> </form>

View File

@@ -43,7 +43,6 @@ export class LoginComponent extends BaseLoginComponent implements OnInit {
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions; enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[]; policies: Policy[];
showPasswordless = false; showPasswordless = false;
constructor( constructor(
private acceptOrganizationInviteService: AcceptOrganizationInviteService, private acceptOrganizationInviteService: AcceptOrganizationInviteService,
devicesApiService: DevicesApiServiceAbstraction, devicesApiService: DevicesApiServiceAbstraction,
@@ -92,7 +91,13 @@ export class LoginComponent extends BaseLoginComponent implements OnInit {
this.onSuccessfulLoginNavigate = this.goAfterLogIn; this.onSuccessfulLoginNavigate = this.goAfterLogIn;
this.showPasswordless = flagEnabled("showPasswordless"); this.showPasswordless = flagEnabled("showPasswordless");
} }
submitForm = async (showToast = true) => {
return await this.submitFormHelper(showToast);
};
private async submitFormHelper(showToast: boolean) {
await super.submit(showToast);
}
async ngOnInit() { async ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe // eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.queryParams.pipe(first()).subscribe(async (qParams) => { this.route.queryParams.pipe(first()).subscribe(async (qParams) => {

View File

@@ -66,7 +66,6 @@ const routes: Routes = [
children: [], // Children lets us have an empty component. children: [], // Children lets us have an empty component.
canActivate: [redirectGuard()], // Redirects either to vault, login, or lock page. canActivate: [redirectGuard()], // Redirects either to vault, login, or lock page.
}, },
{ path: "login", component: LoginComponent, canActivate: [UnauthGuard] },
{ {
path: "login-with-device", path: "login-with-device",
component: LoginViaAuthRequestComponent, component: LoginViaAuthRequestComponent,
@@ -182,6 +181,24 @@ const routes: Routes = [
path: "", path: "",
component: AnonLayoutWrapperComponent, component: AnonLayoutWrapperComponent,
children: [ children: [
{
path: "login",
canActivate: [unauthGuardFn()],
children: [
{
path: "",
component: LoginComponent,
},
{
path: "",
component: EnvironmentSelectorComponent,
outlet: "environment-selector",
},
],
data: {
pageTitle: "logIn",
},
},
{ {
path: "2fa", path: "2fa",
component: TwoFactorComponent, component: TwoFactorComponent,