@agilesoft/ags_authrest2 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/index.js +20 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -132,10 +132,28 @@ class Auth {
132
132
  var isExpiredToken = false;
133
133
 
134
134
  var dateNow = new Date();
135
+ if (payload.exp) {
136
+ if (payload.exp.toString().length > 10) {
137
+ payload.exp = parseInt(
138
+ payload.exp.toString().substr(0, 10)
139
+ );
140
+ }
141
+ // console.log(
142
+ // `${payload.exp} < ${parseInt(
143
+ // new Date().getTime().toString().slice(0, -3)
144
+ // )}`
145
+ // );
135
146
 
136
- if (payload.exp < dateNow.getTime()) {
137
- isExpiredToken = true;
147
+ if (
148
+ payload.exp <
149
+ parseInt(new Date().getTime().toString().slice(0, -3))
150
+ ) {
151
+ isExpiredToken = true;
152
+ }
153
+ } else {
154
+ isExpiredToken = false;
138
155
  }
156
+
139
157
  if (payload.sub === R_USER && isExpiredToken === false) {
140
158
  const chk = await check(req.headers.authorization);
141
159
  // console.log(chk);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilesoft/ags_authrest2",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "This version has been deprecated",
5
5
  "main": "index.js",
6
6
  "scripts": {