aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/services')
-rw-r--r--ufund-ui/src/app/services/users.service.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts
index 28cc266..b3bbbd4 100644
--- a/ufund-ui/src/app/services/users.service.ts
+++ b/ufund-ui/src/app/services/users.service.ts
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
-import {firstValueFrom, Observable, of, Subject} from 'rxjs';
+import {BehaviorSubject, firstValueFrom, Observable} from 'rxjs';
import {User} from '../models/User';
@Injectable({
@@ -8,7 +8,7 @@ import {User} from '../models/User';
})
export class UsersService {
- private currentUser : Subject<User> = new Subject();
+ private currentUser : BehaviorSubject<User | null> = new BehaviorSubject<User | null>(null);
private apiKey: string = "";
private url = "http://localhost:8080/users"
@@ -48,10 +48,14 @@ export class UsersService {
return this.http.delete<boolean>(`${this.url}/${id}`, this.httpOptions)
}
- getCurrentUser() {
+ getCurrentUserSubject() {
return this.currentUser;
}
+ getCurrentUser() {
+ return this.currentUser.getValue()
+ }
+
async login(username: string, password: string) {
let res = this.http.post<string>(this.authUrl, {username: username, password: password}, this.httpOptions2);
this.apiKey = await firstValueFrom(res);