You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
upload-file-backend/src/api/routes/v1/user.route.js

66 lines
1.6 KiB

import express from 'express';
import validate from 'express-validation';
import { authorize } from '../../middlewares/auth.middleware';
import middleware from '../../middlewares/user.middleware';
import controller from '../../controllers/v1/user.controller';
import permissions from '../../../common/utils/Permissions';
import {
listValidation,
updateValidation,
createValidation,
} from '../../validations/v1/user.validation';
const router = express.Router();
router
.route('/')
.get(
authorize([permissions.STAFF]),
validate(listValidation),
middleware.countUser,
controller.list
)
.post(
authorize([permissions.STAFF]),
validate(createValidation),
// authorize([permissions.USER_CREATE]),
middleware.checkEmail,
controller.create
);
router
.route('/:id')
.get(
middleware.load,
controller.get
)
.put(
validate(updateValidation),
authorize([permissions.STAFF]),
middleware.load,
controller.update
)
.delete(
authorize([permissions.STAFF]),
middleware.load,
controller.delete
);
router.route("/:id/reset-password").
post(
authorize([permissions.USER]),
middleware.load,
middleware.checkCurrentPassword,
controller.updatePassword
);
router.route("/change-password/:id").
post(
authorize([permissions.STAFF]),
middleware.load,
// middleware.checkCurrentPassword,
controller.updatePassword
);
export default router;