mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-24 11:55:50 +01:00
stub out 2fa component
This commit is contained in:
parent
8f7ae6cfaa
commit
0328977c14
@ -46,7 +46,7 @@ export class LoginComponent {
|
||||
const response = await this.formPromise;
|
||||
if (response.twoFactor) {
|
||||
this.analytics.eventTrack.next({ action: 'Logged In To Two-step' });
|
||||
this.router.navigate(['twoFactor']);
|
||||
this.router.navigate(['2fa']);
|
||||
// TODO: pass 2fa info
|
||||
} else {
|
||||
this.analytics.eventTrack.next({ action: 'Logged In' });
|
||||
|
24
src/app/accounts/two-factor.component.html
Normal file
24
src/app/accounts/two-factor.component.html
Normal file
@ -0,0 +1,24 @@
|
||||
<form id="register-page" #form (ngSubmit)="submit()" [appApiAction]="formPromise">
|
||||
<div class="content">
|
||||
<h1>{{title}}</h1>
|
||||
<div class="box last">
|
||||
<div class="box-content">
|
||||
<div class="box-content-row" appBoxRow>
|
||||
<label for="code">{{'verificationCode' | i18n}}</label>
|
||||
<input id="code" type="text" name="Code" [(ngModel)]="token" required appAutofocus>
|
||||
</div>
|
||||
<div class="box-content-row box-content-row-checkbox" appBoxRow>
|
||||
<label for="remember">{{'verificationCode' | i18n}}</label>
|
||||
<input id="remember" type="checkbox" [(ngModel)]="remember">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button type="submit" class="btn primary block" [disabled]="form.loading" appBlurClick>
|
||||
<span [hidden]="form.loading">{{'continue' | i18n}}</span>
|
||||
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
|
||||
</button>
|
||||
<a routerLink="/login" class="btn block">{{'cancel' | i18n}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
55
src/app/accounts/two-factor.component.ts
Normal file
55
src/app/accounts/two-factor.component.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import * as template from './two-factor.component.html';
|
||||
|
||||
import {
|
||||
Component,
|
||||
} from '@angular/core';
|
||||
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Angulartics2 } from 'angulartics2';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { RegisterRequest } from 'jslib/models/request/registerRequest';
|
||||
|
||||
import { ApiService } from 'jslib/abstractions/api.service';
|
||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-two-factor',
|
||||
template: template,
|
||||
})
|
||||
export class TwoFactorComponent {
|
||||
token: string = '';
|
||||
remember: boolean = false;
|
||||
providerType: number;
|
||||
email: string;
|
||||
masterPassword: string;
|
||||
formPromise: Promise<any>;
|
||||
|
||||
constructor(private authService: AuthService, private router: Router, private analytics: Angulartics2,
|
||||
private toasterService: ToasterService, private i18nService: I18nService,
|
||||
private cryptoService: CryptoService, private apiService: ApiService) { }
|
||||
|
||||
async submit() {
|
||||
if (this.token == null || this.token === '') {
|
||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('verificationCodeRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: stop U2f
|
||||
// TODO: normalize token
|
||||
|
||||
try {
|
||||
this.formPromise = this.authService.logIn(this.email, this.masterPassword, this.providerType,
|
||||
this.token, this.remember);
|
||||
await this.formPromise;
|
||||
this.analytics.eventTrack.next({ action: 'Logged In From Two-step' });
|
||||
this.router.navigate(['vault']);
|
||||
} catch {
|
||||
// TODO: start U2F
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,13 @@ import {
|
||||
import { HintComponent } from './accounts/hint.component';
|
||||
import { LoginComponent } from './accounts/login.component';
|
||||
import { RegisterComponent } from './accounts/register.component';
|
||||
import { TwoFactorComponent } from './accounts/two-factor.component';
|
||||
import { VaultComponent } from './vault/vault.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/login', pathMatch: 'full' },
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: '2fa', component: TwoFactorComponent },
|
||||
{ path: 'register', component: RegisterComponent },
|
||||
{ path: 'vault', component: VaultComponent },
|
||||
{ path: 'hint', component: HintComponent },
|
||||
|
@ -31,6 +31,7 @@ import { RegisterComponent } from './accounts/register.component';
|
||||
import { SearchCiphersPipe } from './pipes/search-ciphers.pipe';
|
||||
import { StopClickDirective } from './directives/stop-click.directive';
|
||||
import { StopPropDirective } from './directives/stop-prop.directive';
|
||||
import { TwoFactorComponent } from './accounts/two-factor.component';
|
||||
import { VaultComponent } from './vault/vault.component';
|
||||
import { ViewComponent } from './vault/view.component';
|
||||
|
||||
@ -69,6 +70,7 @@ import { ViewComponent } from './vault/view.component';
|
||||
SearchCiphersPipe,
|
||||
StopClickDirective,
|
||||
StopPropDirective,
|
||||
TwoFactorComponent,
|
||||
VaultComponent,
|
||||
ViewComponent,
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user