Update representation controller and routes
This commit is contained in:
@@ -285,7 +285,7 @@ module.exports.add_representation = [
|
||||
const representation = new Representation(data)
|
||||
const user = await User.findById(user_id)
|
||||
if (!user) {
|
||||
res404(res,"آین کاربر در دیتای ما وجود ندارد")
|
||||
res404(res, 'آین کاربر در دیتای ما وجود ندارد')
|
||||
} else {
|
||||
await representation.save()
|
||||
}
|
||||
@@ -1114,8 +1114,11 @@ module.exports.revoke_representation_by_admin = [
|
||||
try {
|
||||
const { user_id } = req
|
||||
if (!user_id) return res406(res, 'invalid user id')
|
||||
const representation = await Representation.findByIdAndUpdate(req.params?.id)
|
||||
const agentAccount = await User.findById(representation.user_id)
|
||||
const representation = await Representation.findOne({ _id: req.params?.id }).populate('user_id')
|
||||
if (!representation) return res404(res, 'Representation not found')
|
||||
|
||||
const agentAccount = await User.findOne({ _id: representation.user_id })
|
||||
if (!agentAccount) return res404(res, 'Agent account not found')
|
||||
|
||||
representation._revoked = true
|
||||
representation._revokedBy = user_id
|
||||
|
||||
Reference in New Issue
Block a user