Bugfixes
This commit is contained in:
@@ -4,7 +4,7 @@ import { jwtDecode } from 'jwt-decode';
|
||||
import { Observable, distinctUntilChanged, filter, from, lastValueFrom, map } from 'rxjs';
|
||||
import urlcat from 'urlcat';
|
||||
import { User } from '../../../../bizmatch-server/src/models/db.model';
|
||||
import { JwtToken, ListingCriteria, ResponseUsersArray } from '../../../../bizmatch-server/src/models/main.model';
|
||||
import { JwtToken, KeycloakUser, ListingCriteria, ResponseUsersArray, StatesResult } from '../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { KeycloakService } from './keycloak.service';
|
||||
|
||||
@@ -16,8 +16,8 @@ export class UserService {
|
||||
// -----------------------------
|
||||
// Keycloak services
|
||||
// -----------------------------
|
||||
private user$ = new Observable<User>();
|
||||
private user: User;
|
||||
private user$ = new Observable<KeycloakUser>();
|
||||
private user: KeycloakUser;
|
||||
public $isLoggedIn: Signal<boolean>;
|
||||
constructor(public keycloak: KeycloakService, private http: HttpClient) {
|
||||
this.user$ = from(this.keycloak.getToken()).pipe(
|
||||
@@ -56,12 +56,12 @@ export class UserService {
|
||||
this.user = this.map2User(token);
|
||||
}
|
||||
|
||||
private map2User(jwt: string): User {
|
||||
private map2User(jwt: string): KeycloakUser {
|
||||
const token = jwtDecode<JwtToken>(jwt);
|
||||
return {
|
||||
id: token.user_id,
|
||||
firstname: token.given_name,
|
||||
lastname: token.family_name,
|
||||
firstName: token.given_name,
|
||||
lastName: token.family_name,
|
||||
email: token.email,
|
||||
};
|
||||
}
|
||||
@@ -69,10 +69,10 @@ export class UserService {
|
||||
isLoggedIn(): boolean {
|
||||
return this.$isLoggedIn();
|
||||
}
|
||||
getKeycloakUser(): User {
|
||||
getKeycloakUser(): KeycloakUser {
|
||||
return this.user;
|
||||
}
|
||||
getUserObservable(): Observable<User> {
|
||||
getUserObservable(): Observable<KeycloakUser> {
|
||||
return this.user$;
|
||||
}
|
||||
async getId(): Promise<string> {
|
||||
@@ -119,4 +119,7 @@ export class UserService {
|
||||
async search(criteria?: ListingCriteria): Promise<ResponseUsersArray> {
|
||||
return await lastValueFrom(this.http.post<ResponseUsersArray>(`${this.apiBaseUrl}/bizmatch/user/search`, criteria));
|
||||
}
|
||||
async getAllStates(): Promise<any> {
|
||||
return await lastValueFrom(this.http.get<StatesResult[]>(`${this.apiBaseUrl}/bizmatch/user/states/all`));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user