Convert observables to signals.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { copy } from '../../core/utils/ObjectUtils';
|
||||
import { FormError } from '../../core/model/FormError';
|
||||
import { UserRestService } from '../../core/rest-services/user/user.rest-service';
|
||||
import { LoginRequest } from '../../core/rest-services/user/model/login.model';
|
||||
import { AuthenticationService } from '../../core/service/authentication.service';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Router } from '@angular/router';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {copy} from '../../core/utils/ObjectUtils';
|
||||
import {FormError} from '../../core/model/FormError';
|
||||
import {UserRestService} from '../../core/rest-services/user/user.rest-service';
|
||||
import {LoginRequest} from '../../core/rest-services/user/model/login.model';
|
||||
import {AuthenticationService} from '../../core/service/authentication.service';
|
||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
export interface LoginState {
|
||||
request: LoginRequest;
|
||||
@@ -65,15 +65,15 @@ export class LoginService {
|
||||
.login(state.request)
|
||||
.then((response) => {
|
||||
this.authenticationService.authenticate(response.accessToken, response.refreshToken);
|
||||
this.snackBar.open($localize`Authentication succeeded!`, $localize`Close`, { duration: 5000 });
|
||||
this.snackBar.open($localize`Authentication succeeded!`, $localize`Close`, {duration: 5000});
|
||||
this.router.navigate(['/home']);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
this.snackBar.open($localize`Authentication failed.`, $localize`Close`, { duration: 5000 });
|
||||
this.snackBar.open($localize`Authentication failed.`, $localize`Close`, {duration: 5000});
|
||||
});
|
||||
} else {
|
||||
this.snackBar.open($localize`Please, fill the inputs before send.`, $localize`Close`, { duration: 5000 });
|
||||
this.snackBar.open($localize`Please, fill the inputs before send.`, $localize`Close`, {duration: 5000});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user