edit:module:user | add middlewware for authenticated only
This commit is contained in:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user