Skip to content

Commit

Permalink
Merge pull request #26 from danial117/server_dev_8
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
danial117 committed Aug 22, 2024
2 parents 07032e2 + f4a22ff commit eb45031
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package-lock.json
public/
.env
npm
.gitigonre
.gitignore
Binary file added 1724303412081-Dr._Hauschka.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions middlewares/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,13 @@ export const verifyAccessToken = (req, res, next) => {
if (!user || !user.isAdmin) {
return res.status(403).json({ message: 'Access denied' });
}

req.user = user;
else{
req.user = user;
next();

}


} catch (err) {
console.log(err)
res.status(401).json({ message: 'Invalid token' });
Expand Down
12 changes: 6 additions & 6 deletions routers/brand.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GetAdminBrands,AdminCreateBrand,GetBrands,GetBrandProducts, AdminModify
import { upload } from '../middlewares/multerConfig.js';
import { modifiedBrandFile } from '../middlewares/fileModified.js';


import { adminAuthenticateJwt } from '../middlewares/auth.js';


router.get('/',GetBrands)
Expand All @@ -16,11 +16,11 @@ router.get('/name/:brandName',GetBrandProducts)

//Admin Routes

router.post('/create',upload.single('file'),AdminCreateBrand)
router.get('/show',GetAdminBrands)
router.get('/show/:brandId',AdminGetBrand)
router.put('/id/:brandId',upload.single('file'),modifiedBrandFile,AdminModifyBrand)
router.delete('/:brandId',AdminDeleteBrand)
router.post('/create',adminAuthenticateJwt,upload.single('file'),AdminCreateBrand)
router.get('/show',adminAuthenticateJwt,GetAdminBrands)
router.get('/show/:brandId',adminAuthenticateJwt,AdminGetBrand)
router.put('/id/:brandId',adminAuthenticateJwt,upload.single('file'),modifiedBrandFile,AdminModifyBrand)
router.delete('/:brandId,',adminAuthenticateJwt,AdminDeleteBrand)



Expand Down
2 changes: 1 addition & 1 deletion routers/customerContact.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ router.post('/request',CustomerContact)


//admin routes
router.get('/show',AdminGetUserContacts)
router.get('/show',adminAuthenticateJwt,AdminGetUserContacts)
router.get('/show/:contactId',adminAuthenticateJwt,AdminGetContact)
router.delete('/:contactId',adminAuthenticateJwt,AdminDeleteContact)

Expand Down

0 comments on commit eb45031

Please sign in to comment.