zek 14.2.58 → 14.2.60
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/lib/components/base.component.mjs +3 -3
- package/esm2020/lib/components/list-base.component.mjs +3 -3
- package/esm2020/lib/models/login.model.mjs +1 -1
- package/esm2020/lib/modules/list-toolbar/list-toolbar.component.mjs +3 -3
- package/esm2020/lib/services/auth.service.mjs +50 -38
- package/esm2020/lib/services/web.api.mjs +2 -2
- package/fesm2015/zek.mjs +52 -40
- package/fesm2015/zek.mjs.map +1 -1
- package/fesm2020/zek.mjs +52 -40
- package/fesm2020/zek.mjs.map +1 -1
- package/lib/models/login.model.d.ts +9 -2
- package/lib/services/auth.service.d.ts +9 -8
- package/package.json +1 -1
package/fesm2015/zek.mjs
CHANGED
|
@@ -1110,22 +1110,34 @@ class UrlHelper {
|
|
|
1110
1110
|
|
|
1111
1111
|
class AuthService {
|
|
1112
1112
|
constructor() {
|
|
1113
|
-
this.
|
|
1114
|
-
this.
|
|
1115
|
-
this.
|
|
1116
|
-
this.
|
|
1113
|
+
this._isInitialized = false;
|
|
1114
|
+
this._subject = new BehaviorSubject(false); //todo check if need BehaviorSubject
|
|
1115
|
+
this._oldValueIsAuthenticated = false;
|
|
1116
|
+
this._user = null;
|
|
1117
|
+
}
|
|
1118
|
+
get user() {
|
|
1119
|
+
if (!this._isInitialized) {
|
|
1120
|
+
let tmp = StorageHelper.get('login');
|
|
1121
|
+
if (tmp) {
|
|
1122
|
+
tmp.expired = DateHelper.parseDate(tmp.expired);
|
|
1123
|
+
tmp.refreshTokenTime = DateHelper.parseDate(tmp.refreshTokenTime);
|
|
1124
|
+
}
|
|
1125
|
+
this._user = tmp;
|
|
1126
|
+
this._isInitialized = true;
|
|
1127
|
+
}
|
|
1128
|
+
return this._user;
|
|
1117
1129
|
}
|
|
1130
|
+
// private _expired: Date | null = null;
|
|
1131
|
+
// private _refreshTokenExpired: Date | null = null;
|
|
1118
1132
|
isAuthenticated() {
|
|
1119
|
-
let expired = this.getExpired();
|
|
1120
|
-
if (!expired)
|
|
1121
|
-
expired = new Date(0);
|
|
1133
|
+
let expired = this.getExpired() || new Date(0);
|
|
1122
1134
|
const newValue = new Date() < expired;
|
|
1123
|
-
if (this.
|
|
1124
|
-
this.
|
|
1135
|
+
if (this._oldValueIsAuthenticated != newValue) {
|
|
1136
|
+
this._oldValueIsAuthenticated = newValue;
|
|
1125
1137
|
if (this.onSignedInSubject) {
|
|
1126
1138
|
this.onSignedInSubject.next(newValue);
|
|
1127
1139
|
}
|
|
1128
|
-
this.
|
|
1140
|
+
this._subject.next(newValue);
|
|
1129
1141
|
//if user is signed in and expired we need to logout (remove from localStorage)
|
|
1130
1142
|
if (!newValue) {
|
|
1131
1143
|
this.logout();
|
|
@@ -1138,7 +1150,7 @@ class AuthService {
|
|
|
1138
1150
|
* @deprecated The method should not be used. please use onSignedIn
|
|
1139
1151
|
*/
|
|
1140
1152
|
isSignedIn() {
|
|
1141
|
-
return this.
|
|
1153
|
+
return this._subject.asObservable();
|
|
1142
1154
|
}
|
|
1143
1155
|
get onSignedIn() {
|
|
1144
1156
|
if (!this.onSignedInSubject) {
|
|
@@ -1149,39 +1161,39 @@ class AuthService {
|
|
|
1149
1161
|
throw new Error("onExecuteObservable is undefined");
|
|
1150
1162
|
return this.onSignedInObservable;
|
|
1151
1163
|
}
|
|
1152
|
-
login(
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
//this.permissionsService.flushPermissions();
|
|
1157
|
-
if (tmp.roles) {
|
|
1158
|
-
tmp.roles = tmp.roles.map(function (e) { return e.toUpperCase(); });
|
|
1159
|
-
//this.permissionsService.loadPermissions(model.roles);
|
|
1164
|
+
login(user) {
|
|
1165
|
+
if (user) {
|
|
1166
|
+
if (Array.isArray(user.roles)) {
|
|
1167
|
+
user.roles = user.roles.map(function (e) { return e.toUpperCase(); });
|
|
1160
1168
|
}
|
|
1161
1169
|
}
|
|
1162
|
-
|
|
1163
|
-
this.
|
|
1164
|
-
this.
|
|
1165
|
-
StorageHelper.set('login', this.model);
|
|
1170
|
+
StorageHelper.set('login', user);
|
|
1171
|
+
this._user = null;
|
|
1172
|
+
this._isInitialized = false;
|
|
1166
1173
|
this.isAuthenticated(); //this method need to execute subject.next();
|
|
1167
1174
|
}
|
|
1168
1175
|
logout() {
|
|
1169
1176
|
this.login(null);
|
|
1170
1177
|
}
|
|
1171
|
-
getUser() {
|
|
1172
|
-
|
|
1173
|
-
|
|
1178
|
+
// getUser(): LoginToken | null {
|
|
1179
|
+
// if (!this.model) {
|
|
1180
|
+
// this.model = StorageHelper.get('login');
|
|
1181
|
+
// }
|
|
1182
|
+
// return this.model;
|
|
1183
|
+
// }
|
|
1184
|
+
getExpired() {
|
|
1185
|
+
let user = this.user;
|
|
1186
|
+
if (user) {
|
|
1187
|
+
return user.expired;
|
|
1174
1188
|
}
|
|
1175
|
-
return
|
|
1189
|
+
return null;
|
|
1176
1190
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
this.expired = new Date(tmp.expired);
|
|
1182
|
-
}
|
|
1191
|
+
getRefreshTokenExpired() {
|
|
1192
|
+
let user = this.user;
|
|
1193
|
+
if (user) {
|
|
1194
|
+
return user.refreshTokenTime;
|
|
1183
1195
|
}
|
|
1184
|
-
return
|
|
1196
|
+
return null;
|
|
1185
1197
|
}
|
|
1186
1198
|
// isInRole(allowedRoles: string[]): boolean {
|
|
1187
1199
|
// if (!allowedRoles || allowedRoles.length === 0) {
|
|
@@ -1217,8 +1229,8 @@ class AuthService {
|
|
|
1217
1229
|
if (!permissions || permissions.length === 0) {
|
|
1218
1230
|
return true;
|
|
1219
1231
|
}
|
|
1220
|
-
const
|
|
1221
|
-
const userPermissions =
|
|
1232
|
+
const user = this.user;
|
|
1233
|
+
const userPermissions = user ? user.permissions : null;
|
|
1222
1234
|
if (!userPermissions) {
|
|
1223
1235
|
return false;
|
|
1224
1236
|
}
|
|
@@ -1729,7 +1741,7 @@ class WebApiClient {
|
|
|
1729
1741
|
getHeaders() {
|
|
1730
1742
|
let httpHeaders = new HttpHeaders();
|
|
1731
1743
|
httpHeaders = httpHeaders.set('Content-Type', 'application/json');
|
|
1732
|
-
const tmp = this.authService.
|
|
1744
|
+
const tmp = this.authService.user;
|
|
1733
1745
|
const token = tmp ? tmp.token : undefined;
|
|
1734
1746
|
if (token)
|
|
1735
1747
|
httpHeaders = httpHeaders.set('Authorization', token);
|
|
@@ -1847,7 +1859,7 @@ class BaseComponent extends CoreComponent {
|
|
|
1847
1859
|
}
|
|
1848
1860
|
get url() {
|
|
1849
1861
|
if (!this._url)
|
|
1850
|
-
this._url = this.router.url
|
|
1862
|
+
this._url = UrlHelper.getNoParam(this.router.url);
|
|
1851
1863
|
return this._url;
|
|
1852
1864
|
}
|
|
1853
1865
|
getParam(name) {
|
|
@@ -2457,7 +2469,7 @@ class ListBaseComponent extends BaseComponent {
|
|
|
2457
2469
|
this.bindModel();
|
|
2458
2470
|
}
|
|
2459
2471
|
create() {
|
|
2460
|
-
const url = this.router.url
|
|
2472
|
+
const url = UrlHelper.getNoParam(this.router.url);
|
|
2461
2473
|
this.router.navigate([url, 'create', { returnUrl: url + ';filter=1' }]);
|
|
2462
2474
|
}
|
|
2463
2475
|
delete(id) {
|
|
@@ -4538,7 +4550,7 @@ class ListToolbarComponent {
|
|
|
4538
4550
|
this.onRefresh.emit();
|
|
4539
4551
|
}
|
|
4540
4552
|
create() {
|
|
4541
|
-
const url = this.router.url
|
|
4553
|
+
const url = UrlHelper.getNoParam(this.router.url);
|
|
4542
4554
|
this.router.navigate([url, 'create', { returnUrl: url + ';filter=1' }]);
|
|
4543
4555
|
}
|
|
4544
4556
|
filter() {
|