mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
🐛 fix checktoken
This commit is contained in:
parent
ef4f32e597
commit
5000f8e518
@ -4,7 +4,7 @@ export * as Constants from "./util/Constants";
|
|||||||
export * from "./models/index";
|
export * from "./models/index";
|
||||||
export * from "./util/index";
|
export * from "./util/index";
|
||||||
|
|
||||||
import Config, { DefaultOptions } from "./util/Config";
|
import Config from "./util/Config";
|
||||||
import db, { MongooseCache, toObject } from "./util/Database";
|
import db, { MongooseCache, toObject } from "./util/Database";
|
||||||
|
|
||||||
export { Config, db, DefaultOptions, MongooseCache, toObject };
|
export { Config, db, MongooseCache, toObject };
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { JWTOptions } from "./Constants";
|
import { JWTOptions } from "./Constants";
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import Config from "./Config";
|
|
||||||
|
|
||||||
export function checkToken(token: string): Promise<any> {
|
export function checkToken(token: string, jwtSecret: string): Promise<any> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
jwt.verify(token, Config.getAll()?.api?.security?.jwtSecret, JWTOptions, (err, decoded: any) => {
|
jwt.verify(token, jwtSecret, JWTOptions, (err, decoded: any) => {
|
||||||
if (err || !decoded) return rej("Invalid Token");
|
if (err || !decoded) return rej("Invalid Token");
|
||||||
|
|
||||||
return res(decoded);
|
return res(decoded);
|
||||||
|
Loading…
Reference in New Issue
Block a user