19 lines
465 B
JavaScript
19 lines
465 B
JavaScript
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()
|
|
}
|