@ahi40/common
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -21,3 +21,3 @@ "use strict"; | ||
function NotAuthorizedError() { | ||
var _this = _super.call(this, 'Not Authorized') || this; | ||
var _this = _super.call(this, 'Not Authorized.') || this; | ||
_this.statusCode = 401; | ||
@@ -28,3 +28,3 @@ Object.setPrototypeOf(_this, NotAuthorizedError.prototype); | ||
NotAuthorizedError.prototype.serializeErrors = function () { | ||
return [{ message: 'Not authorized' }]; | ||
return [{ message: 'Not authorized. Possibly token expired. Please try to login again' }]; | ||
}; | ||
@@ -31,0 +31,0 @@ return NotAuthorizedError; |
@@ -5,2 +5,3 @@ import { Request, Response, NextFunction } from 'express'; | ||
email: string; | ||
exp: number; | ||
} | ||
@@ -7,0 +8,0 @@ declare global { |
@@ -15,3 +15,2 @@ "use strict"; | ||
var payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY); | ||
console.log(payload); | ||
req.currentUser = payload; | ||
@@ -18,0 +17,0 @@ } |
@@ -9,3 +9,6 @@ "use strict"; | ||
} | ||
if (req.currentUser.exp < Date.now().valueOf() / 1000) { | ||
throw new not_authorized_error_1.NotAuthorizedError(); | ||
} | ||
next(); | ||
}; |
{ | ||
"name": "@ahi40/common", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
21163
474