Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Aug 5, 2022
1 parent 82c07f0 commit 51b3453
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ export const protect = catchAsync(
) {
token = req.headers.authorization.split(' ')[1];
}
// else if (!req.session) {
// throw new AppError(
// 'You are not logged in! Please login to get access.',
// 401
// );
// }

if (!token) {
throw new AppError(
Expand All @@ -35,8 +29,6 @@ export const protect = catchAsync(
const secret = configuration().jwt.secret;
const decoded: any = jwt.verify(token, secret);

// const decoded: any = await promisify(jwt.verify)(token, secret);

// Check if user still exits
const user = await UserModel.findById(decoded.id);

Expand All @@ -55,7 +47,7 @@ export const restrictTo = (...roles: string[]) => {
try {
// roles ['admin', 'user']

if (!roles.includes(req.user?.role as string)) {
if (!roles.includes(req.user.role as string)) {
throw new AppError(
'You do not have permission to perform this action',
403
Expand Down

0 comments on commit 51b3453

Please sign in to comment.