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';
|
2019-06-04 06:06:15 +02:00
|
|
|
import { EnvironmentService } from 'jslib/abstractions/environment.service';
|
2018-06-09 19:59:09 +02:00
|
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
2019-02-13 21:32:41 +01:00
|
|
|
import { LockService } from 'jslib/abstractions/lock.service';
|
2018-06-09 19:59:09 +02:00
|
|
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
|
|
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
2019-07-02 14:44:29 +02:00
|
|
|
import { StateService } from 'jslib/abstractions/state.service';
|
2019-02-13 21:32:41 +01:00
|
|
|
import { StorageService } from 'jslib/abstractions/storage.service';
|
2018-06-09 19:59:09 +02:00
|
|
|
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,
|
2019-02-13 21:32:41 +01:00
|
|
|
storageService: StorageService, lockService: LockService,
|
2019-07-02 14:44:29 +02:00
|
|
|
environmentService: EnvironmentService, private routerService: RouterService,
|
|
|
|
stateService: StateService) {
|
2019-02-13 21:32:41 +01:00
|
|
|
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService,
|
2019-07-02 14:44:29 +02:00
|
|
|
storageService, lockService, environmentService, stateService);
|
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
|
|
|
|
2019-02-22 19:17:10 +01:00
|
|
|
this.onSuccessfulSubmit = () => {
|
|
|
|
const previousUrl = this.routerService.getPreviousUrl();
|
|
|
|
if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) {
|
|
|
|
this.successRoute = previousUrl;
|
|
|
|
}
|
|
|
|
this.router.navigate([this.successRoute]);
|
|
|
|
};
|
2018-06-10 04:02:45 +02:00
|
|
|
}
|
2018-06-09 19:59:09 +02:00
|
|
|
}
|