|
|
|
@ -22,13 +22,15 @@ import { Constants } from '@shared/models/constants'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { OAuth2ClientLoginInfo } from '@shared/models/oauth2.models'; |
|
|
|
import { validateEmail } from '@app/core/utils'; |
|
|
|
import { PageComponent } from '@shared/components/page.component'; |
|
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'tb-login', |
|
|
|
templateUrl: './login.component.html', |
|
|
|
styleUrls: ['./login.component.scss'] |
|
|
|
}) |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
export class LoginComponent extends PageComponent implements OnInit { |
|
|
|
|
|
|
|
passwordViolation = false; |
|
|
|
isLoading = false; |
|
|
|
@ -42,6 +44,7 @@ export class LoginComponent implements OnInit { |
|
|
|
constructor(private authService: AuthService, |
|
|
|
public fb: UntypedFormBuilder, |
|
|
|
private router: Router) { |
|
|
|
super(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
@ -51,10 +54,10 @@ export class LoginComponent implements OnInit { |
|
|
|
login(): void { |
|
|
|
if (this.loginFormGroup.valid) { |
|
|
|
this.isLoading = true; |
|
|
|
this.authService.login(this.loginFormGroup.value).subscribe({ |
|
|
|
next: () => {}, |
|
|
|
this.authService.login(this.loginFormGroup.value).pipe( |
|
|
|
finalize(() => {this.isLoading = false;}) |
|
|
|
).subscribe({ |
|
|
|
error: (error: HttpErrorResponse) => { |
|
|
|
this.isLoading = false; |
|
|
|
if (error && error.error && error.error.errorCode) { |
|
|
|
if (error.error.errorCode === Constants.serverErrorCode.credentialsExpired) { |
|
|
|
this.router.navigateByUrl(`login/resetExpiredPassword?resetToken=${error.error.resetToken}`); |
|
|
|
|