This repository has been archived on 2026-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
ServerSpacebarOld/src/util/checkToken.ts
2021-04-08 11:43:26 -03:00

14 lines
391 B
TypeScript

import { JWTOptions } from "./Constants";
import jwt from "jsonwebtoken";
import Config from "./Config";
export function checkToken(token: string): Promise<any> {
return new Promise((res, rej) => {
jwt.verify(token, Config.getAll()?.api?.security?.jwtSecret, JWTOptions, (err, decoded: any) => {
if (err || !decoded) return rej("Invalid Token");
return res(decoded);
});
});
}