Skip to content

Commit b269a90

Browse files
committed
add isAuthenticated method to user service
1 parent f080d27 commit b269a90

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

projects/fusio-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-fusio-sdk",
3-
"version": "7.0.0",
3+
"version": "7.0.1",
44
"description": "SDK to integrate Fusio into an Angular app",
55
"keywords": [
66
"Fusio",

projects/fusio-sdk/src/lib/service/user.service.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,17 @@ import {ConfigService} from "./config.service";
99
})
1010
export class UserService {
1111

12-
private user?: ConsumerUserAccount;
13-
1412
constructor(private fusio: FusioService, private config: ConfigService) { }
1513

1614
public login(user: ConsumerUserAccount): void {
17-
this.user = user;
1815
sessionStorage.setItem(this.getKey(), JSON.stringify(user));
1916
}
2017

2118
public get(): ConsumerUserAccount|undefined {
22-
if (!this.fusio.hasValidToken()) {
19+
if (!this.isAuthenticated()) {
2320
return undefined;
2421
}
2522

26-
if (this.user) {
27-
return this.user;
28-
}
29-
3023
const rawData = sessionStorage.getItem(this.getKey());
3124
if (!rawData) {
3225
return undefined;
@@ -35,8 +28,11 @@ export class UserService {
3528
return JSON.parse(rawData);
3629
}
3730

31+
public isAuthenticated(): boolean {
32+
return this.fusio.hasValidToken();
33+
}
34+
3835
public logout(): void {
39-
this.user = undefined;
4036
sessionStorage.removeItem(this.getKey());
4137
this.fusio.logout();
4238
}

0 commit comments

Comments
 (0)