Skip to content

Commit

Permalink
Refactor: removed unused middleware function
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Sep 15, 2024
1 parent 68dbf41 commit b47fe69
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/middleware/auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { asyncHandler } from '@sliit-foss/functions';
import { default as createError } from 'http-errors';
import { ROLE } from '@/constants';
import { isBlacklistedToken } from '@/repository/token';
import { getOneUser } from '@/repository/user';
import { decodeJwtToken } from '@/utils';
Expand All @@ -24,11 +23,6 @@ export const protect = asyncHandler(async (req) => {
req.user = user;
});

export const adminProtect = asyncHandler((req) => {
if (req.headers['x-api-key'] === process.env.API_ACCESS_KEY) return;
if (req.user?.role !== ROLE.ADMIN) throw new createError(403, 'You are not permitted to access this resource');
});

export const roleProtect = (roles = []) => {
return asyncHandler((req) => {
if (req.headers['x-api-key'] === process.env.API_ACCESS_KEY) return;
Expand Down

0 comments on commit b47fe69

Please sign in to comment.