diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-15 17:28:01 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-15 17:28:01 -0400 |
commit | 51f0322db803ed3baf1f24f18a6e7a83dab58a3b (patch) | |
tree | f252383812cf1131199fa147feb0eca7639b520a /ufund-ui/src/app/services | |
parent | 4f2f1d0944b15ced834255cd2934516a953b97a5 (diff) | |
download | JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.tar.gz JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.tar.bz2 JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.zip |
Add login redirection
Diffstat (limited to 'ufund-ui/src/app/services')
-rw-r--r-- | ufund-ui/src/app/services/users.service.ts | 10 |
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); |