full
This commit is contained in:
18
middlewares/requirePostExpertise.js
Normal file
18
middlewares/requirePostExpertise.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const { userHasPostExpertise, respondPostExpertiseRequired } = require('../utils/postProfile')
|
||||
|
||||
/** برای ثبت پست، تخصص کاربر باید مشخص شده باشد */
|
||||
module.exports = (req, res, next) => {
|
||||
const user = req.user
|
||||
if (!user) {
|
||||
return res.status(401).json({
|
||||
error: true,
|
||||
message: 'You are not authorized!',
|
||||
})
|
||||
}
|
||||
|
||||
if (!userHasPostExpertise(user)) {
|
||||
return respondPostExpertiseRequired(res)
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
Reference in New Issue
Block a user