fix: token bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { map, switchMap, tap } from 'rxjs/operators';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { LoginRequest, RegisterRequest, RegisterResponse, LoginResponse, CurrentUser } from '../models/auth.models';
|
||||
|
||||
@@ -42,16 +42,9 @@ export class AuthService {
|
||||
email
|
||||
})
|
||||
.pipe(
|
||||
tap((response) => {
|
||||
localStorage.setItem('username', response.username);
|
||||
localStorage.setItem('userId', response.id);
|
||||
this.currentUserSubject.next({
|
||||
id: response.id,
|
||||
username: response.username,
|
||||
rating: response.rating,
|
||||
createdAt: response.createdAt
|
||||
});
|
||||
})
|
||||
switchMap((response) =>
|
||||
this.login(username, password).pipe(map(() => response))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user