satisfy quality tools
This commit is contained in:
parent
df9fa9f275
commit
2326d41a96
3 changed files with 15 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { KeycloakProfile } from 'keycloak-js';
|
||||
import { async, Observable } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { User } from '../model/User';
|
||||
|
||||
@Injectable({
|
||||
|
@ -10,8 +10,8 @@ import { User } from '../model/User';
|
|||
export class UserService {
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
|
||||
public getUser(id: string): Observable<User|null> {
|
||||
return this.http.get<User|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): Observable<User> {
|
||||
|
@ -25,11 +25,13 @@ export class UserService {
|
|||
if (userProfile.id == null) {
|
||||
return;
|
||||
}
|
||||
return await this.getUser(userProfile.id).toPromise().then(async user => {
|
||||
if (user) {
|
||||
return user;
|
||||
}
|
||||
return await this.createUser(userProfile.id ?? '', userProfile.username ?? '').toPromise();
|
||||
});
|
||||
return await this.getUser(userProfile.id)
|
||||
.toPromise()
|
||||
.then(async (user) => {
|
||||
if (user) {
|
||||
return user;
|
||||
}
|
||||
return await this.createUser(userProfile.id ?? '', userProfile.username ?? '').toPromise();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue