2019-01-08 06:32:35 +01:00
|
|
|
import { Component } from '@angular/core';
|
2018-06-09 19:59:09 +02:00
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
|
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
|
|
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
|
|
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
|
|
|
import { UserService } from 'jslib/abstractions/user.service';
|
|
|
|
|
2018-06-10 04:40:53 +02:00
|
|
|
import { RouterService } from '../services/router.service';
|
|
|
|
|
2018-06-09 19:59:09 +02:00
|
|
|
import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-lock',
|
|
|
|
templateUrl: 'lock.component.html',
|
|
|
|
})
|
2019-01-08 06:32:35 +01:00
|
|
|
export class LockComponent extends BaseLockComponent {
|
2018-10-03 16:33:04 +02:00
|
|
|
constructor(router: Router, i18nService: I18nService,
|
2018-06-09 19:59:09 +02:00
|
|
|
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
|
2018-06-10 04:40:53 +02:00
|
|
|
userService: UserService, cryptoService: CryptoService,
|
|
|
|
private routerService: RouterService) {
|
2018-10-03 16:33:04 +02:00
|
|
|
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService);
|
2018-06-09 19:59:09 +02:00
|
|
|
}
|
2018-06-10 04:02:45 +02:00
|
|
|
|
|
|
|
async ngOnInit() {
|
2019-01-08 06:32:35 +01:00
|
|
|
await super.ngOnInit();
|
2018-06-10 04:02:45 +02:00
|
|
|
const authed = await this.userService.isAuthenticated();
|
|
|
|
if (!authed) {
|
|
|
|
this.router.navigate(['/']);
|
2018-06-13 23:21:27 +02:00
|
|
|
} else if (await this.cryptoService.hasKey()) {
|
2018-06-10 04:02:45 +02:00
|
|
|
this.router.navigate(['vault']);
|
|
|
|
}
|
2018-06-10 04:40:53 +02:00
|
|
|
|
|
|
|
const previousUrl = this.routerService.getPreviousUrl();
|
|
|
|
if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) {
|
|
|
|
this.successRoute = previousUrl;
|
|
|
|
}
|
2018-06-10 04:02:45 +02:00
|
|
|
}
|
2018-06-09 19:59:09 +02:00
|
|
|
}
|