edit:module:user | add middlewware for authenticated only

This commit is contained in:
2025-06-22 09:52:22 +07:00
parent 48946be6b7
commit 181e6f3688
3 changed files with 7 additions and 6 deletions

View File

@ -3,11 +3,11 @@ import { getCookie } from "../../helpers/http/userHeader/cookies/getCookies";
import { returnErrorResponse } from "../../helpers/callback/httpResponse";
import { mainErrorHandler } from "../../helpers/error/handler";
export const authMiddleware = (ctx: Context) => {
export const authenticatedMiddleware = (ctx: Context) => {
try {
const cookie = getCookie(ctx);
if (!cookie.auth_token)
return returnErrorResponse(ctx.set, 401, "User Unauthorized");
return returnErrorResponse(ctx.set, 401, "User Unauthenticated");
// pass
} catch (error) {