@lenne.tech/ng-base 14.28.1 → 14.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/shared/services/auth.service.mjs +20 -3
- package/fesm2015/lenne.tech-ng-base-shared.mjs +19 -2
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs +19 -2
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/package.json +1 -1
- package/shared/services/auth.service.d.ts +1 -0
|
@@ -1010,8 +1010,13 @@ class AuthService {
|
|
|
1010
1010
|
// Subjects
|
|
1011
1011
|
this._currentUser = new BehaviorSubject(null);
|
|
1012
1012
|
this._token = new BehaviorSubject(null);
|
|
1013
|
-
this.
|
|
1014
|
-
|
|
1013
|
+
this.loadFromStorage();
|
|
1014
|
+
}
|
|
1015
|
+
loadFromStorage() {
|
|
1016
|
+
if (localStorage) {
|
|
1017
|
+
this.token = this.storageService.load('token');
|
|
1018
|
+
this.currentUser = this.storageService.load('currentUser');
|
|
1019
|
+
}
|
|
1015
1020
|
}
|
|
1016
1021
|
/**
|
|
1017
1022
|
* Logout
|
|
@@ -1028,6 +1033,9 @@ class AuthService {
|
|
|
1028
1033
|
if (!localStorage) {
|
|
1029
1034
|
return undefined;
|
|
1030
1035
|
}
|
|
1036
|
+
else if (!this._currentUser.value) {
|
|
1037
|
+
this.loadFromStorage();
|
|
1038
|
+
}
|
|
1031
1039
|
return this._currentUser.value;
|
|
1032
1040
|
}
|
|
1033
1041
|
set currentUser(user) {
|
|
@@ -1035,6 +1043,9 @@ class AuthService {
|
|
|
1035
1043
|
this.storageService.save('currentUser', user);
|
|
1036
1044
|
}
|
|
1037
1045
|
get currentUserObservable() {
|
|
1046
|
+
if (!this._currentUser.value) {
|
|
1047
|
+
this.loadFromStorage();
|
|
1048
|
+
}
|
|
1038
1049
|
return this._currentUser.asObservable();
|
|
1039
1050
|
}
|
|
1040
1051
|
// #################################################################
|
|
@@ -1044,6 +1055,9 @@ class AuthService {
|
|
|
1044
1055
|
if (!localStorage) {
|
|
1045
1056
|
return undefined;
|
|
1046
1057
|
}
|
|
1058
|
+
else if (this._token.value) {
|
|
1059
|
+
this.loadFromStorage();
|
|
1060
|
+
}
|
|
1047
1061
|
return this._token.value;
|
|
1048
1062
|
}
|
|
1049
1063
|
set token(token) {
|
|
@@ -1052,6 +1066,9 @@ class AuthService {
|
|
|
1052
1066
|
this.wsService.reconnect();
|
|
1053
1067
|
}
|
|
1054
1068
|
get tokenObservable() {
|
|
1069
|
+
if (!this._token.value) {
|
|
1070
|
+
this.loadFromStorage();
|
|
1071
|
+
}
|
|
1055
1072
|
return this._token.asObservable();
|
|
1056
1073
|
}
|
|
1057
1074
|
}
|