summary refs log tree commit diff
path: root/dist/checkToken.js
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-05 16:14:17 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-05 16:14:17 +0100
commit996878cbe3eefed32fbf87e172b98e43df355f19 (patch)
tree0db9abb57eb429c370c989fbd1d353dd41dc699b /dist/checkToken.js
parent:wrench: build (diff)
downloadserver-996878cbe3eefed32fbf87e172b98e43df355f19.tar.xz
:art: rename Database -> db
Diffstat (limited to 'dist/checkToken.js')
-rw-r--r--dist/checkToken.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/dist/checkToken.js b/dist/checkToken.js
new file mode 100644

index 00000000..17d88178 --- /dev/null +++ b/dist/checkToken.js
@@ -0,0 +1,20 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.checkToken = void 0; +const Constants_1 = require("./Constants"); +const jsonwebtoken_1 = __importDefault(require("jsonwebtoken")); +const Config_1 = __importDefault(require("./Config")); +function checkToken(token) { + return new Promise((res, rej) => { + jsonwebtoken_1.default.verify(token, Config_1.default.getAll().api.security.jwtSecret, Constants_1.JWTOptions, (err, decoded) => { + if (err || !decoded) + return rej("Invalid Token"); + return res(decoded); + }); + }); +} +exports.checkToken = checkToken; +//# sourceMappingURL=checkToken.js.map \ No newline at end of file