Update representation controller and routes

This commit is contained in:
mahyargdz
2025-05-01 09:39:16 +03:30
parent 5fecf350e7
commit a771f7e199
@@ -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