share login component with jslib
This commit is contained in:
parent
def6bd7874
commit
0303b18e2e
2
jslib
2
jslib
|
@ -1 +1 @@
|
|||
Subproject commit 579f970323ea0bbc0d26f17cb9454c142f47bf6a
|
||||
Subproject commit 7b4d0a71de640ce14c3c446bfd2e8ce36635db3f
|
|
@ -14,57 +14,24 @@ import { Angulartics2 } from 'angulartics2';
|
|||
import { ModalComponent } from '../modal.component';
|
||||
import { EnvironmentComponent } from './environment.component';
|
||||
|
||||
import { AuthResult } from 'jslib/models/domain/authResult';
|
||||
|
||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { SyncService } from 'jslib/abstractions/sync.service';
|
||||
|
||||
import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
template: template,
|
||||
})
|
||||
export class LoginComponent {
|
||||
export class LoginComponent extends BaseLoginComponent {
|
||||
@ViewChild('environment', { read: ViewContainerRef }) environmentModal: ViewContainerRef;
|
||||
|
||||
email: string = '';
|
||||
masterPassword: string = '';
|
||||
showPassword: boolean = false;
|
||||
formPromise: Promise<AuthResult>;
|
||||
|
||||
constructor(private authService: AuthService, private router: Router, private analytics: Angulartics2,
|
||||
private toasterService: ToasterService, private i18nService: I18nService, private syncService: SyncService,
|
||||
private componentFactoryResolver: ComponentFactoryResolver) { }
|
||||
|
||||
async submit() {
|
||||
if (this.email == null || this.email === '') {
|
||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('emailRequired'));
|
||||
return;
|
||||
}
|
||||
if (this.email.indexOf('@') === -1) {
|
||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('invalidEmail'));
|
||||
return;
|
||||
}
|
||||
if (this.masterPassword == null || this.masterPassword === '') {
|
||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('masterPassRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.formPromise = this.authService.logIn(this.email, this.masterPassword);
|
||||
const response = await this.formPromise;
|
||||
if (response.twoFactor) {
|
||||
this.analytics.eventTrack.next({ action: 'Logged In To Two-step' });
|
||||
this.router.navigate(['2fa']);
|
||||
} else {
|
||||
this.syncService.fullSync(true);
|
||||
this.analytics.eventTrack.next({ action: 'Logged In' });
|
||||
this.router.navigate(['vault']);
|
||||
}
|
||||
} catch { }
|
||||
constructor(authService: AuthService, router: Router,
|
||||
analytics: Angulartics2, toasterService: ToasterService,
|
||||
i18nService: I18nService, syncService: SyncService,
|
||||
private componentFactoryResolver: ComponentFactoryResolver) {
|
||||
super(authService, router, analytics, toasterService, i18nService, syncService);
|
||||
}
|
||||
|
||||
settings() {
|
||||
|
@ -77,10 +44,4 @@ export class LoginComponent {
|
|||
modal.close();
|
||||
});
|
||||
}
|
||||
|
||||
togglePassword() {
|
||||
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Login' });
|
||||
this.showPassword = !this.showPassword;
|
||||
document.getElementById('masterPassword').focus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
"types": [],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"jslib/*": [ "jslib/src/*" ]
|
||||
"jslib/*": [ "jslib/src/*" ],
|
||||
"@angular/*": [ "node_modules/@angular/*" ],
|
||||
"angular2-toaster": [ "node_modules/angular2-toaster" ],
|
||||
"angulartics2": [ "node_modules/angulartics2" ]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
|
|
Loading…
Reference in New Issue