diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-31 13:12:42 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-31 13:12:42 -0400 |
commit | 655f83af9ba59d6153c9916b9a31bfe12680655e (patch) | |
tree | 6508f52a52da1b45b257a0042c4c3433a7225838 /ufund-ui/src/app/services/auth.service.ts | |
parent | 5f083f775917c15597b3b70a0eb6a0ce2fda7667 (diff) | |
download | JellySolutions-655f83af9ba59d6153c9916b9a31bfe12680655e.tar.gz JellySolutions-655f83af9ba59d6153c9916b9a31bfe12680655e.tar.bz2 JellySolutions-655f83af9ba59d6153c9916b9a31bfe12680655e.zip |
Implemented localStorage cookies to maintain user persistence
Diffstat (limited to 'ufund-ui/src/app/services/auth.service.ts')
-rw-r--r-- | ufund-ui/src/app/services/auth.service.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ufund-ui/src/app/services/auth.service.ts b/ufund-ui/src/app/services/auth.service.ts index 6bc7145..b75c931 100644 --- a/ufund-ui/src/app/services/auth.service.ts +++ b/ufund-ui/src/app/services/auth.service.ts @@ -1,7 +1,8 @@ -import {Injectable} from '@angular/core'; +import {Injectable, Injector} from '@angular/core'; import {BehaviorSubject, firstValueFrom} from 'rxjs'; import {User} from '../models/User'; import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {UsersService} from './users.service'; @Injectable({ providedIn: 'root' @@ -24,7 +25,9 @@ export class AuthService { }); constructor( - private http: HttpClient + private http: HttpClient, + // private userService: UsersService + private injector: Injector ) {} async login(username: string, password: string) { @@ -42,6 +45,13 @@ export class AuthService { // this.currentUser.subscribe(r => console.log("currentUser: "+r.username)) } + async restoreLogin(username: string, key: string) { + + const userService = this.injector.get(UsersService); + this.apiKey = key; + this.currentUser.next(await firstValueFrom(userService.getUser(username))) + } + getCurrentUserSubject() { return this.currentUser; } |