migration

This commit is contained in:
_Bastler
2022-01-21 22:38:31 +01:00
parent 5cf6230005
commit 578e6e6981
36 changed files with 1473 additions and 1012 deletions
@@ -1,14 +1,14 @@
import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {Auth2FAService} from '../../services/auth.2fa.service';
import {Router, ActivatedRoute} from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Auth2FAService } from '../../services/auth.2fa.service';
import { Router, ActivatedRoute } from '@angular/router';
import {environment} from '../../../environments/environment';
import { environment } from '../../../environments/environment';
@Component({
selector: 'app-login',
templateUrl: './login-totp.component.html',
styleUrls: ['./login-totp.component.scss']
styleUrls: [ './login-totp.component.scss' ]
})
export class LoginTotpComponent implements OnInit {
@@ -17,29 +17,34 @@ export class LoginTotpComponent implements OnInit {
public apiUrl = environment.apiUrl;
targetRoute = '/account/info';
constructor(private formBuilder: FormBuilder, private auth2FAService: Auth2FAService, private router: Router, private route: ActivatedRoute) {}
constructor(private formBuilder: FormBuilder, private auth2FAService: Auth2FAService, private router: Router, private route: ActivatedRoute) { }
ngOnInit() {
this.form = this.formBuilder.group({
code: ['', Validators.required],
keep: ['']
code: [ '', Validators.required ],
keep: [ '' ]
});
this.route.queryParams.subscribe(params => {
if(params['target']) {
this.targetRoute = params['target'];
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
}
}
});
}
async loginTotp() {
this.loginInvalid = false;
if(this.form.valid) {
this.auth2FAService.login('totp', this.form.get('code').value, this.form.get('keep').value).subscribe((response: any) => {
this.router.navigate([this.targetRoute]);
}, error => {
this.loginInvalid = true;
if (this.form.valid) {
this.auth2FAService.login('totp', this.form.get('code').value, this.form.get('keep').value).subscribe({
next: (response: any) => {
this.router.navigate([ this.targetRoute ]);
},
error: (error) => {
this.loginInvalid = true;
}
});
}