feat/logout #17

Merged
vivy-agent merged 5 commits from feat/logout into main 2026-02-18 13:03:29 +07:00
2 changed files with 5 additions and 3 deletions
Showing only changes of commit 3122f34093 - Show all commits

View File

@ -9,7 +9,7 @@ export const jwtDecode = (payload: string) => {
try { try {
const decodedPayload = jwt.verify(payload, JWTKey); const decodedPayload = jwt.verify(payload, JWTKey);
return decodedPayload as JWTAuthToken; return decodedPayload as JWTAuthToken;
} catch (error) { } catch {
throw new AppError(401, "Invalid or expired token", error); throw new AppError(403, "Invalid or expired token");
} }
}; };

View File

@ -1,9 +1,11 @@
import { AppError } from "../../../../helpers/error/instances/app";
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder"; import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
import { jwtDecode } from "../../../../helpers/http/jwt/decode"; import { jwtDecode } from "../../../../helpers/http/jwt/decode";
export const tokenValidationService = (payload: string) => { export const tokenValidationService = (payload: string) => {
try { try {
if (!payload) return null; if (!payload || payload.trim() === "")
throw new AppError(401, "Unauthorized: No token provided");
const decoded = jwtDecode(payload); const decoded = jwtDecode(payload);
return decoded; return decoded;
} catch (error) { } catch (error) {