Merge
This commit is contained in:
@@ -570,17 +570,14 @@ module.exports.update_user = [
|
||||
const user = await User.findById(user_id)
|
||||
if (!user) return res404(res, _faSr.not_found.user_id)
|
||||
|
||||
// check if need to ferify email or mobile
|
||||
const newEmail = user.email !== MongoData.email
|
||||
const newMobile = user.mobile_number !== MongoData.mobile_number
|
||||
if (newEmail) user.email_confirmed = false
|
||||
if (newMobile) user.mobile_confirmed = false
|
||||
|
||||
// save new info to arpa
|
||||
await updateUserOnArpa(MongoData, user.verity_businessID, 'verity')
|
||||
await updateUserOnArpa(MongoData, user.panatech_businessID, 'panatech')
|
||||
|
||||
// save new info to user
|
||||
user.first_name = MongoData.first_name
|
||||
user.last_name = MongoData.last_name
|
||||
user.national_code = MongoData.national_code
|
||||
@@ -597,11 +594,10 @@ module.exports.update_user = [
|
||||
|
||||
await user.save()
|
||||
|
||||
// send confirmation key after user saved
|
||||
if (newEmail) await sendConfirmationEmail(user_id)
|
||||
if (newMobile) await sendConfirmationSMS(user_id)
|
||||
|
||||
return res.json({ message: _faSr.response.success_save })
|
||||
return res.json({ message: _faSr.response.success_save , data:user })
|
||||
} catch (e) {
|
||||
console.log('Arpa Error during update user --', e)
|
||||
return res500(res, _faSr.response.problem)
|
||||
|
||||
Reference in New Issue
Block a user