add:module:user:repository:checkUserEmailAndUsernameAvailabillity | add repository for check username and email availabillity
This commit is contained in:
@ -1,14 +1,16 @@
|
||||
import jwt from "jsonwebtoken";
|
||||
import { JWTSessionPayload } from "../../../../modules/auth/auth.types";
|
||||
import { AppError } from "../../../error/instances/app";
|
||||
|
||||
export const jwtDecode = (payload: string) => {
|
||||
// return payload;
|
||||
if (!payload) throw "JWT decode payload not found";
|
||||
if (!payload) throw new AppError(401, "Unauthorized");
|
||||
const JWTKey = process.env.JWT_SECRET!;
|
||||
|
||||
try {
|
||||
const decodedPayload = jwt.verify(payload, JWTKey);
|
||||
return decodedPayload;
|
||||
return decodedPayload as JWTSessionPayload;
|
||||
} catch (error) {
|
||||
throw "JWT expired or not valid";
|
||||
throw new AppError(401, "Invalid or expired token");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user