bitwarden-estensione-browser/src/app/accounts/login.component.ts

48 lines
1.7 KiB
TypeScript
Raw Normal View History

2018-06-05 21:02:53 +02:00
import { Component } from '@angular/core';
2018-07-13 15:13:37 +02:00
import {
ActivatedRoute,
Router,
} from '@angular/router';
2018-06-05 21:02:53 +02:00
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { AuthService } from 'jslib/abstractions/auth.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { StateService } from 'jslib/abstractions/state.service';
2018-07-13 15:13:37 +02:00
import { StorageService } from 'jslib/abstractions/storage.service';
2018-06-05 21:02:53 +02:00
import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component';
@Component({
selector: 'app-login',
templateUrl: 'login.component.html',
})
export class LoginComponent extends BaseLoginComponent {
constructor(authService: AuthService, router: Router,
analytics: Angulartics2, toasterService: ToasterService,
2018-07-13 15:13:37 +02:00
i18nService: I18nService, private route: ActivatedRoute,
storageService: StorageService, private stateService: StateService) {
2018-07-13 15:13:37 +02:00
super(authService, router, analytics, toasterService, i18nService, storageService);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
2018-06-05 21:02:53 +02:00
}
2018-07-13 15:13:37 +02:00
async ngOnInit() {
this.route.queryParams.subscribe(async (qParams) => {
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email;
}
await super.ngOnInit();
});
}
async goAfterLogIn() {
const invite = await this.stateService.get<any>('orgInvitation');
if (invite != null) {
this.router.navigate(['accept-organization'], { queryParams: invite });
} else {
this.router.navigate([this.successRoute]);
}
}
2018-06-05 21:02:53 +02:00
}