new: Add agent by admin
This commit is contained in:
+280
-14
@@ -77,19 +77,165 @@
|
|||||||
</CCard>
|
</CCard>
|
||||||
|
|
||||||
<el-dialog :visible.sync="addAgentModal">
|
<el-dialog :visible.sync="addAgentModal">
|
||||||
<el-select v-model="selectedUserForNewAgent" style="width: 100%" label="کاربر را انتخاب کنید" filterable>
|
<CRow>
|
||||||
<el-option
|
<CCol lg="12" xl="12" md="12" style="margin-bottom: 10px">
|
||||||
v-for="item in users"
|
<h4>اضافه کردن نماینده با اکانت قبلی</h4>
|
||||||
:key="item._id"
|
<el-select v-model="selectedUserForNewAgent" style="width: 100%" label="کاربر را انتخاب کنید" filterable>
|
||||||
:label="item.first_name + ' ' + item.last_name + ' (' + item.national_code + ')'"
|
<el-option
|
||||||
:value="item._id"
|
v-for="item in users"
|
||||||
></el-option>
|
:key="item._id"
|
||||||
</el-select>
|
:label="item.first_name + ' ' + item.last_name + ' (' + item.national_code + ')'"
|
||||||
<br />
|
:value="item._id"
|
||||||
<br />
|
></el-option>
|
||||||
<el-button type="success" :disabled="!selectedUserForNewAgent" @click="addAgent">
|
</el-select>
|
||||||
<span style="color: #fff">افزودن</span>
|
<br />
|
||||||
</el-button>
|
<br />
|
||||||
|
<el-button type="success" :disabled="!selectedUserForNewAgent" @click="addAgent">
|
||||||
|
<span style="color: #fff">افزودن</span>
|
||||||
|
</el-button>
|
||||||
|
</CCol>
|
||||||
|
<el-divider></el-divider>
|
||||||
|
<CCol>
|
||||||
|
<h4>اضافه کردن نماینده با اکانت جدید</h4>
|
||||||
|
<CForm>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.first_name"
|
||||||
|
label="نام"
|
||||||
|
horizontal
|
||||||
|
:description="validation.first_name ? validation.first_name.msg : null"
|
||||||
|
:class="validation.first_name ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.last_name"
|
||||||
|
label="نام خانوادگی"
|
||||||
|
horizontal
|
||||||
|
:description="validation.last_name ? validation.last_name.msg : null"
|
||||||
|
:class="validation.last_name ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.national_code"
|
||||||
|
label="کد ملی"
|
||||||
|
horizontal
|
||||||
|
:description="validation.national_code ? validation.national_code.msg : null"
|
||||||
|
:class="validation.national_code ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.mobile_number"
|
||||||
|
label="شماره همراه"
|
||||||
|
horizontal
|
||||||
|
:description="validation.mobile_number ? validation.mobile_number.msg : null"
|
||||||
|
:class="validation.mobile_number ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.tel_number"
|
||||||
|
label="شماره ثابت"
|
||||||
|
horizontal
|
||||||
|
:description="validation.tel_number ? validation.tel_number.msg : null"
|
||||||
|
:class="validation.tel_number ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.email"
|
||||||
|
label="ایمیل "
|
||||||
|
horizontal
|
||||||
|
:description="validation.email ? validation.email.msg : null"
|
||||||
|
:class="validation.email ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.store_name"
|
||||||
|
label="نام فروشگاه"
|
||||||
|
horizontal
|
||||||
|
:description="validation.store_name ? validation.store_name.msg : null"
|
||||||
|
:class="validation.store_name ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<label>استان</label>
|
||||||
|
<el-select
|
||||||
|
v-model="registerData.province_id"
|
||||||
|
filterable
|
||||||
|
placeholder="استان را انتخاب کنید"
|
||||||
|
style="width: 75%"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in iranProvinces"
|
||||||
|
:key="item.ProvinceID"
|
||||||
|
:label="item.ProvinceName"
|
||||||
|
:value="item.ProvinceID"
|
||||||
|
>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
<p v-if="validation.province_id">{{ validation.province_id.msg }}</p>
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<label style="padding-left: 10px">شهر </label>
|
||||||
|
<el-select
|
||||||
|
v-model="registerData.city_id"
|
||||||
|
filterable
|
||||||
|
:placeholder="provinceCities ? 'شهر را انتخاب کنید' : 'ابتدا استان را انتخاب کنید'"
|
||||||
|
style="width: 75%"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in provinceCities"
|
||||||
|
:key="item.CityID"
|
||||||
|
:label="item.CityName"
|
||||||
|
:value="item.CityID"
|
||||||
|
>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
<p v-if="validation.city_id">{{ validation.city_id.msg }}</p>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.address"
|
||||||
|
label="آدرس "
|
||||||
|
horizontal
|
||||||
|
:description="validation.address ? validation.address.msg : null"
|
||||||
|
:class="validation.address ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.postal_code"
|
||||||
|
label="کد پستی "
|
||||||
|
horizontal
|
||||||
|
:description="validation.postal_code ? validation.postal_code.msg : null"
|
||||||
|
:class="validation.postal_code ? 'err' : null"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.password"
|
||||||
|
label="کلمه عبور"
|
||||||
|
horizontal
|
||||||
|
type="password"
|
||||||
|
:description="validation.password ? validation.password.msg : null"
|
||||||
|
:class="validation.password ? 'err' : null"
|
||||||
|
/>
|
||||||
|
<CInput
|
||||||
|
v-model="registerData.password_confirmation"
|
||||||
|
label="تکرار کلمه عبور"
|
||||||
|
horizontal
|
||||||
|
type="password"
|
||||||
|
:description="validation.password_confirmation ? validation.password_confirmation.msg : null"
|
||||||
|
:class="validation.password_confirmation ? 'err' : null"
|
||||||
|
/>
|
||||||
|
</CForm>
|
||||||
|
<el-button type="success" :disabled="!registerData" @click="addUserAndAgent">
|
||||||
|
<span style="color: #fff">افزودن</span>
|
||||||
|
</el-button>
|
||||||
|
</CCol>
|
||||||
|
</CRow>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -121,7 +267,29 @@ export default {
|
|||||||
users: [],
|
users: [],
|
||||||
filterText: '',
|
filterText: '',
|
||||||
addAgentModal: false,
|
addAgentModal: false,
|
||||||
selectedUserForNewAgent: null
|
selectedUserForNewAgent: null,
|
||||||
|
registerData: {
|
||||||
|
userID: '',
|
||||||
|
first_name: '',
|
||||||
|
last_name: '',
|
||||||
|
national_code: '',
|
||||||
|
province_id: '',
|
||||||
|
province_name: '',
|
||||||
|
city_id: '',
|
||||||
|
city_name: '',
|
||||||
|
address: '',
|
||||||
|
postal_code: '',
|
||||||
|
tel_number: '',
|
||||||
|
mobile_number: '',
|
||||||
|
email: '',
|
||||||
|
store_name: '',
|
||||||
|
password: '',
|
||||||
|
password_confirmation: ''
|
||||||
|
},
|
||||||
|
iranCities: [],
|
||||||
|
iranProvinces: [],
|
||||||
|
provinceCities: null,
|
||||||
|
validation: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
head() {
|
head() {
|
||||||
@@ -130,6 +298,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
selectedProvince() {
|
||||||
|
return this.registerData.province_id
|
||||||
|
},
|
||||||
|
selectedCity() {
|
||||||
|
return this.registerData.city_id
|
||||||
|
},
|
||||||
revokedAgentsList() {
|
revokedAgentsList() {
|
||||||
return this.$route.query?.revoked
|
return this.$route.query?.revoked
|
||||||
},
|
},
|
||||||
@@ -158,14 +332,106 @@ export default {
|
|||||||
},
|
},
|
||||||
addAgentModal(newVal, oldVal) {
|
addAgentModal(newVal, oldVal) {
|
||||||
this.selectedUserForNewAgent = null
|
this.selectedUserForNewAgent = null
|
||||||
|
},
|
||||||
|
selectedProvince(newVal, oldVal) {
|
||||||
|
// step 1
|
||||||
|
this.registerData.city_id = ''
|
||||||
|
// step 2
|
||||||
|
if (newVal)
|
||||||
|
this.registerData.province_name = this.iranProvinces.filter(item => item.ProvinceID === newVal)[0].ProvinceName
|
||||||
|
else this.registerData.province_name = ''
|
||||||
|
// step 3
|
||||||
|
if (newVal) this.provinceCities = this.iranCities.filter(item => item.ProvinceID === newVal)
|
||||||
|
else this.provinceCities = null
|
||||||
|
},
|
||||||
|
selectedCity(newVal, oldVal) {
|
||||||
|
if (newVal) this.registerData.city_name = this.iranCities.filter(item => item.CityID === newVal)[0].CityName
|
||||||
|
else this.registerData.city_name = ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$axios.$get('/api/admin/users').then(res => {
|
this.$axios.$get('/api/admin/users').then(res => {
|
||||||
this.users = res
|
this.users = res
|
||||||
})
|
})
|
||||||
|
this.$axios
|
||||||
|
.post('/api/cross/getRouteManager', {
|
||||||
|
url: '/api/GetProvince',
|
||||||
|
db: 'verity'
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
this.iranProvinces = res.data.data
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.$arpaError()
|
||||||
|
console.log('provinces list fetch error -- ', err)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$axios
|
||||||
|
.post('/api/cross/getRouteManager', {
|
||||||
|
url: '/api/GetCity',
|
||||||
|
db: 'verity'
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
this.iranCities = res.data.data
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.$arpaError()
|
||||||
|
console.log('cities list fetch error -- ', err)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
addUserAndAgent() {
|
||||||
|
this.validation = {}
|
||||||
|
|
||||||
|
this.$axios
|
||||||
|
.post('/api/admin/user', this.registerData)
|
||||||
|
.then(response => {
|
||||||
|
this.registerData = {
|
||||||
|
userID: response.data.user._id,
|
||||||
|
first_name: '',
|
||||||
|
last_name: '',
|
||||||
|
national_code: '',
|
||||||
|
province_id: '',
|
||||||
|
province_name: '',
|
||||||
|
city_id: '',
|
||||||
|
city_name: '',
|
||||||
|
address: '',
|
||||||
|
postal_code: '',
|
||||||
|
tel_number: '',
|
||||||
|
mobile_number: '',
|
||||||
|
email: '',
|
||||||
|
store_name: '',
|
||||||
|
password: '',
|
||||||
|
password_confirmation: ''
|
||||||
|
}
|
||||||
|
console.log(this.registerData)
|
||||||
|
|
||||||
|
this.$axios
|
||||||
|
.$post('/api/admin/addAgentByAdmin', { user: response.data.user._id })
|
||||||
|
.then(res => {
|
||||||
|
this.$router.push({
|
||||||
|
name: 'admin-agents-agent',
|
||||||
|
params: { agent: res.representationId },
|
||||||
|
query: { ...this.$route.query }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: err.response.data.message
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.response.status === 422) {
|
||||||
|
this.validation = error.response.data.validation
|
||||||
|
} else
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: error.response.data.message
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
addAgent() {
|
addAgent() {
|
||||||
if (!this.selectedUserForNewAgent) {
|
if (!this.selectedUserForNewAgent) {
|
||||||
return this.$message({
|
return this.$message({
|
||||||
|
|||||||
@@ -205,9 +205,9 @@ module.exports.update_admin = [
|
|||||||
],
|
],
|
||||||
checkValidations(validationResult),
|
checkValidations(validationResult),
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const { username, first_name, last_name, permissions,personalCode } = req.body
|
const { username, first_name, last_name, permissions, personalCode } = req.body
|
||||||
|
|
||||||
const data = { username, first_name, last_name, permissions,personalCode }
|
const data = { username, first_name, last_name, permissions, personalCode }
|
||||||
data._creator = req.user_id
|
data._creator = req.user_id
|
||||||
|
|
||||||
User.findByIdAndUpdate(req.params.id, data, (err, oldData) => {
|
User.findByIdAndUpdate(req.params.id, data, (err, oldData) => {
|
||||||
@@ -597,7 +597,7 @@ module.exports.update_user = [
|
|||||||
if (newEmail) await sendConfirmationEmail(user_id)
|
if (newEmail) await sendConfirmationEmail(user_id)
|
||||||
if (newMobile) await sendConfirmationSMS(user_id)
|
if (newMobile) await sendConfirmationSMS(user_id)
|
||||||
|
|
||||||
return res.json({ message: _faSr.response.success_save , data:user })
|
return res.json({ message: _faSr.response.success_save, data: user })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Arpa Error during update user --', e)
|
console.log('Arpa Error during update user --', e)
|
||||||
return res500(res, _faSr.response.problem)
|
return res500(res, _faSr.response.problem)
|
||||||
@@ -947,8 +947,194 @@ module.exports.confirmMobile = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// //////////////////////////////////////////////////////////////////// user managemnet by admin
|
/// //////////////////////////////////////////////////////////////////// user managemnet by admin
|
||||||
|
|
||||||
|
module.exports.add_user = [
|
||||||
|
[
|
||||||
|
body('first_name')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.first_name)
|
||||||
|
.bail()
|
||||||
|
.isLength({ min: 2 })
|
||||||
|
.withMessage(_faSr.min_char.min2)
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
if (removeWhiteSpaces(value).length < 2) return Promise.reject(_faSr.min_char.min2)
|
||||||
|
if (!isPersian(value)) return Promise.reject(new Error('لطفا با حروف فارسی تایپ کنید'))
|
||||||
|
else return true
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('last_name')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.first_name)
|
||||||
|
.bail()
|
||||||
|
.isLength({ min: 2 })
|
||||||
|
.withMessage(_faSr.min_char.min2)
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
if (removeWhiteSpaces(value).length < 2) return Promise.reject(_faSr.min_char.min2)
|
||||||
|
if (!isPersian(value)) return Promise.reject(new Error('لطفا با حروف فارسی تایپ کنید'))
|
||||||
|
else return true
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('national_code')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.national_code)
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
if (checkNationalCode(value)) return true
|
||||||
|
else return Promise.reject(_faSr.format.national_code)
|
||||||
|
})
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
const nationalCode = value.trim()
|
||||||
|
return User.findOne({ national_code: nationalCode }).then(user => {
|
||||||
|
if (user && user.national_code === nationalCode)
|
||||||
|
return Promise.reject(new Error('کاربر با این کد ملی از قبل وجود دارد'))
|
||||||
|
else return true
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('province_id').notEmpty().withMessage(_faSr.required.province),
|
||||||
|
|
||||||
|
body('city_id').notEmpty().withMessage(_faSr.required.city),
|
||||||
|
|
||||||
|
body('address')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.address)
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
if (!isPersianWithDigits(value)) return Promise.reject(new Error('لطفا با حروف فارسی تایپ کنید'))
|
||||||
|
else return true
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('postal_code')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.postal_code)
|
||||||
|
.bail()
|
||||||
|
.isNumeric()
|
||||||
|
.withMessage(_faSr.format.number),
|
||||||
|
|
||||||
|
body('email')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.email)
|
||||||
|
.bail()
|
||||||
|
.isEmail()
|
||||||
|
.withMessage(_faSr.format.email)
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
const email = value.trim().toLowerCase()
|
||||||
|
return User.findOne({ email }).then(user => {
|
||||||
|
if (user && user.email === email) return Promise.reject(_faSr.duplicated.email)
|
||||||
|
else return true
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('tel_number')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.phone_number)
|
||||||
|
.bail()
|
||||||
|
.isNumeric()
|
||||||
|
.withMessage(_faSr.format.phone_number),
|
||||||
|
|
||||||
|
body('mobile_number')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.phone_number)
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
const mobileNStatus = checkMobileNumber(value)
|
||||||
|
if (!mobileNStatus) return Promise.reject(_faSr.format.phone_number)
|
||||||
|
else return Promise.resolve()
|
||||||
|
})
|
||||||
|
.bail()
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
const mobileNumber = value.trim()
|
||||||
|
return User.findOne({ mobile_number: mobileNumber }).then(user => {
|
||||||
|
if (user && user.mobile_number === mobileNumber)
|
||||||
|
return Promise.reject(new Error('کاربر با این شماره موبایل از قبل وجود دارد'))
|
||||||
|
else return true
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('password')
|
||||||
|
.isLength({ min: 4 })
|
||||||
|
.withMessage(_faSr.min_char.min4)
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
if (value === req.body.password_confirmation) return true
|
||||||
|
else return Promise.reject(_faSr.response.passwords_not_match)
|
||||||
|
})
|
||||||
|
],
|
||||||
|
checkValidations(validationResult),
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
national_code,
|
||||||
|
province_id,
|
||||||
|
province_name,
|
||||||
|
city_id,
|
||||||
|
city_name,
|
||||||
|
address,
|
||||||
|
postal_code,
|
||||||
|
tel_number,
|
||||||
|
mobile_number,
|
||||||
|
email,
|
||||||
|
store_name,
|
||||||
|
password
|
||||||
|
} = req.body
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
last_name,
|
||||||
|
province_id,
|
||||||
|
province_name,
|
||||||
|
city_id,
|
||||||
|
city_name,
|
||||||
|
address,
|
||||||
|
postal_code,
|
||||||
|
tel_number,
|
||||||
|
store_name
|
||||||
|
}
|
||||||
|
data.first_name = nameOptimizer(first_name)
|
||||||
|
data.national_code = national_code.trim()
|
||||||
|
data.mobile_number = normalizeMobileNumber(mobile_number)
|
||||||
|
data.email = email.trim().toLowerCase()
|
||||||
|
data.email_confirmed = true
|
||||||
|
data.mobile_confirmed = true
|
||||||
|
data.confirmed = true
|
||||||
|
|
||||||
|
// hash user password and done
|
||||||
|
const salt = await bcrypt.genSalt(10)
|
||||||
|
const hash = await bcrypt.hash(password, salt)
|
||||||
|
data.password = hash
|
||||||
|
|
||||||
|
const user = new User(data)
|
||||||
|
await user.save()
|
||||||
|
|
||||||
|
const verityID = await saveUserToArpa(user, 'verity')
|
||||||
|
const panatechID = await saveUserToArpa(user, 'panatech')
|
||||||
|
|
||||||
|
user.verity_businessID = verityID.businessID
|
||||||
|
user.verity_businessCode = verityID.businessCode
|
||||||
|
|
||||||
|
user.panatech_businessID = panatechID.businessID
|
||||||
|
user.panatech_businessCode = panatechID.businessCode
|
||||||
|
|
||||||
|
|
||||||
|
// save new info to arpa
|
||||||
|
await updateUserOnArpa(user, user.verity_businessID, 'verity')
|
||||||
|
await updateUserOnArpa(user, user.panatech_businessID, 'panatech')
|
||||||
|
await user.save()
|
||||||
|
|
||||||
|
return res.status(200).json({ message: _faSr.response.success_save, user })
|
||||||
|
} catch (err) {
|
||||||
|
const registerFailurMsg = 'مشکلی در ثبت نام پیش آمده، لطفا مجددا تلاش کنید'
|
||||||
|
res500(res, registerFailurMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
module.exports.get_all_users_for_admin = [
|
module.exports.get_all_users_for_admin = [
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
User.find(
|
User.find(
|
||||||
{
|
{
|
||||||
scope: ['user'],
|
scope: ['user'],
|
||||||
@@ -1175,9 +1361,9 @@ module.exports.update_user_by_admin = [
|
|||||||
MongoData.email = email.trim().toLowerCase()
|
MongoData.email = email.trim().toLowerCase()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user_id = req.params.id
|
const user_id = req.params.id
|
||||||
const user = await User.findById(user_id)
|
const user = await User.findById(user_id)
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res404(res, _faSr.not_found.user_id)
|
return res404(res, _faSr.not_found.user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,7 +1393,7 @@ module.exports.update_user_by_admin = [
|
|||||||
user.mobile_number = MongoData.mobile_number
|
user.mobile_number = MongoData.mobile_number
|
||||||
user.email = MongoData.email
|
user.email = MongoData.email
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await user.save()
|
await user.save()
|
||||||
|
|
||||||
@@ -1365,7 +1551,7 @@ module.exports.updateUserByAdmin = [
|
|||||||
MongoData.email = email.trim().toLowerCase()
|
MongoData.email = email.trim().toLowerCase()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user_id = req.params.id
|
const user_id = req.params.id
|
||||||
const user = await User.findById(user_id)
|
const user = await User.findById(user_id)
|
||||||
if (!user) return res404(res, _faSr.not_found.user_id)
|
if (!user) return res404(res, _faSr.not_found.user_id)
|
||||||
|
|
||||||
@@ -1579,5 +1765,5 @@ module.exports.getUser = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
/// ////////////////////////////////////////////////////////////////////////// GPS Section
|
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ router.put('/user/:id', hasPermission('customers'), userController.updateUserByA
|
|||||||
router.put('/user/changeVerityInfo/:id', hasPermission('customers'), userController.change_verity_info_by_admin)
|
router.put('/user/changeVerityInfo/:id', hasPermission('customers'), userController.change_verity_info_by_admin)
|
||||||
router.put('/user/changePanatechInfo/:id', hasPermission('customers'), userController.change_panatech_info_by_admin)
|
router.put('/user/changePanatechInfo/:id', hasPermission('customers'), userController.change_panatech_info_by_admin)
|
||||||
router.put('/user/update/:id', hasPermission('customers'), userController.update_user_by_admin)
|
router.put('/user/update/:id', hasPermission('customers'), userController.update_user_by_admin)
|
||||||
|
router.post('/user', hasPermission('customers'), userController.add_user)
|
||||||
|
|
||||||
|
|
||||||
/// ///////////// serials exel file
|
/// ///////////// serials exel file
|
||||||
|
|||||||
Reference in New Issue
Block a user