@gridsuite/commons-ui 0.24.0 → 0.24.1
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/lib/utils/AuthService.js +9 -0
- package/package.json +1 -1
package/lib/utils/AuthService.js
CHANGED
|
@@ -147,6 +147,15 @@ function logout(dispatch, userManagerInstance) {
|
|
|
147
147
|
function dispatchUser(dispatch, userManagerInstance) {
|
|
148
148
|
return userManagerInstance.getUser().then(function (user) {
|
|
149
149
|
if (user) {
|
|
150
|
+
var now = parseInt(Date.now() / 1000);
|
|
151
|
+
var exp = (0, _jwtDecode["default"])(user.id_token).exp;
|
|
152
|
+
var idTokenExpiresIn = exp - now;
|
|
153
|
+
|
|
154
|
+
if (idTokenExpiresIn < 0) {
|
|
155
|
+
console.debug('User token is expired and will not be dispatched');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
150
159
|
console.debug('User has been successfully loaded from store.');
|
|
151
160
|
return dispatch((0, _actions.setLoggedUser)(user));
|
|
152
161
|
} else {
|