This commit is contained in:
payacom
2026-08-31 20:45:41 +03:30
parent fa9f23c61d
commit 3f416a7a60
367 changed files with 621895 additions and 6443 deletions

View File

@@ -24,20 +24,26 @@ module.exports = async (req, res, next) => {
}
const user = await UserModel.findById(decodedToken.id)
if (!user) {
return res.status(401).send({
status: 'error',
code: 401,
message: 'Your token is not valid!'
})
}
if (!user.user_name ||
!user.first_name ||
!user.last_name ||
!user.password) {
return res.status(403).send({
status: 'error',
code: 403,
message: 'لطفا از بخش تنظیمات، ثبت نام خود را کامل کنید',
type: 'not_register'
})
}
!user.password ||
!user.user_type) {
return res.status(403).send({
status: 'error',
code: 403,
message: 'لطفا از بخش تنظیمات، ثبت نام خود را کامل کنید',
type: 'not_register'
})
}
req.user = user // کاربر را به درخواست اضافه کنید تا در سایر middleware ها و کنترلرها استفاده شود.
req.user = user
next()
} catch (error) {
console.error('not_register middleware:', error)