summary refs log tree commit diff
path: root/src/util/checkToken.ts
blob: 80896de78e52a839d231be2f5d5e63b71127ef87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import { JWTOptions } from "./Constants";
import jwt from "jsonwebtoken";

export function checkToken(token: string, jwtSecret: string): Promise<any> {
	return new Promise((res, rej) => {
		jwt.verify(token, jwtSecret, JWTOptions, (err, decoded: any) => {
			if (err || !decoded) return rej("Invalid Token");

			return res(decoded);
		});
	});
}