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