fix: fix some stuff
This commit is contained in:
		
					parent
					
						
							
								793f3f6834
							
						
					
				
			
			
				commit
				
					
						df9fa9f275
					
				
			
		
					 10 changed files with 132 additions and 24 deletions
				
			
		|  | @ -1,7 +1,8 @@ | |||
| import { inject, Injectable } from '@angular/core'; | ||||
| import { HttpClient } from '@angular/common/http'; | ||||
| import { KeycloakProfile } from 'keycloak-js'; | ||||
| import { async } from 'rxjs'; | ||||
| import { async, Observable } from 'rxjs'; | ||||
| import { User } from '../model/User'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root', | ||||
|  | @ -9,18 +10,18 @@ import { async } from 'rxjs'; | |||
| export class UserService { | ||||
|   private http: HttpClient = inject(HttpClient); | ||||
| 
 | ||||
|   public getUser(id: string) { | ||||
|     return this.http.get<{ keycloakId: string, username: string } | null>(`/backend/user/${id}`); | ||||
|   public getUser(id: string): Observable<User|null> { | ||||
|     return this.http.get<User|null>(`/backend/user/${id}`); | ||||
|   } | ||||
| 
 | ||||
|   public createUser(id: string, username: string) { | ||||
|     return this.http.post<{ keycloakId: string, username: string }>('/backend/user', { | ||||
|   public createUser(id: string, username: string): Observable<User> { | ||||
|     return this.http.post<User>('/backend/user', { | ||||
|       keycloakId: id, | ||||
|       username: username, | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   public async getCurrentUser(userProfile: KeycloakProfile) { | ||||
|   public async getOrCreateUser(userProfile: KeycloakProfile) { | ||||
|     if (userProfile.id == null) { | ||||
|       return; | ||||
|     } | ||||
|  |  | |||
		Reference in a new issue