1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-15 10:25:21 +01:00

stub out 2fa component

This commit is contained in:
Kyle Spearrin 2018-01-31 22:54:13 -05:00
parent 8f7ae6cfaa
commit 0328977c14
5 changed files with 84 additions and 1 deletions

View File

@ -46,7 +46,7 @@ export class LoginComponent {
const response = await this.formPromise; const response = await this.formPromise;
if (response.twoFactor) { if (response.twoFactor) {
this.analytics.eventTrack.next({ action: 'Logged In To Two-step' }); this.analytics.eventTrack.next({ action: 'Logged In To Two-step' });
this.router.navigate(['twoFactor']); this.router.navigate(['2fa']);
// TODO: pass 2fa info // TODO: pass 2fa info
} else { } else {
this.analytics.eventTrack.next({ action: 'Logged In' }); this.analytics.eventTrack.next({ action: 'Logged In' });

View 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>

View 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
}
}
}

View File

@ -7,11 +7,13 @@ import {
import { HintComponent } from './accounts/hint.component'; import { HintComponent } from './accounts/hint.component';
import { LoginComponent } from './accounts/login.component'; import { LoginComponent } from './accounts/login.component';
import { RegisterComponent } from './accounts/register.component'; import { RegisterComponent } from './accounts/register.component';
import { TwoFactorComponent } from './accounts/two-factor.component';
import { VaultComponent } from './vault/vault.component'; import { VaultComponent } from './vault/vault.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', redirectTo: '/login', pathMatch: 'full' }, { path: '', redirectTo: '/login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent }, { path: 'login', component: LoginComponent },
{ path: '2fa', component: TwoFactorComponent },
{ path: 'register', component: RegisterComponent }, { path: 'register', component: RegisterComponent },
{ path: 'vault', component: VaultComponent }, { path: 'vault', component: VaultComponent },
{ path: 'hint', component: HintComponent }, { path: 'hint', component: HintComponent },

View File

@ -31,6 +31,7 @@ import { RegisterComponent } from './accounts/register.component';
import { SearchCiphersPipe } from './pipes/search-ciphers.pipe'; import { SearchCiphersPipe } from './pipes/search-ciphers.pipe';
import { StopClickDirective } from './directives/stop-click.directive'; import { StopClickDirective } from './directives/stop-click.directive';
import { StopPropDirective } from './directives/stop-prop.directive'; import { StopPropDirective } from './directives/stop-prop.directive';
import { TwoFactorComponent } from './accounts/two-factor.component';
import { VaultComponent } from './vault/vault.component'; import { VaultComponent } from './vault/vault.component';
import { ViewComponent } from './vault/view.component'; import { ViewComponent } from './vault/view.component';
@ -69,6 +70,7 @@ import { ViewComponent } from './vault/view.component';
SearchCiphersPipe, SearchCiphersPipe,
StopClickDirective, StopClickDirective,
StopPropDirective, StopPropDirective,
TwoFactorComponent,
VaultComponent, VaultComponent,
ViewComponent, ViewComponent,
], ],