Fix model & request for gps controller
This commit is contained in:
@@ -39,6 +39,24 @@ const authentication = {
|
|||||||
return res401(res, 'unauthorized')
|
return res401(res, 'unauthorized')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// check if admin logged in (middleware)
|
||||||
|
async isGPS(req, res, next) {
|
||||||
|
try {
|
||||||
|
const token = req.headers?.authorization
|
||||||
|
if (!token) throw new Error('err')
|
||||||
|
|
||||||
|
const decoded = jwt.verify(token.replace(/^Bearer\s/, ''), authentication.secretKey)
|
||||||
|
if (!decoded) throw new Error('err')
|
||||||
|
|
||||||
|
const user = await User.findById(decoded._id)
|
||||||
|
if (!user || !user.scope.includes('gps')) throw new Error('err')
|
||||||
|
|
||||||
|
req.user_id = decoded._id
|
||||||
|
return next()
|
||||||
|
} catch (err) {
|
||||||
|
return res401(res, 'unauthorized')
|
||||||
|
}
|
||||||
|
},
|
||||||
// check if user logged in (middleware)
|
// check if user logged in (middleware)
|
||||||
async isUser(req, res, next) {
|
async isUser(req, res, next) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
const { body, param, validationResult } = require('express-validator')
|
||||||
|
const { _sr } = require('../plugins/serverResponses')
|
||||||
|
const { checkValidations, res400 } = require('../plugins/controllersHelperFunctions')
|
||||||
|
const User = require('../models/User')
|
||||||
|
const RequestGPS = require('../models/GPS.Request')
|
||||||
|
|
||||||
|
module.exports.gpsRequest = [
|
||||||
|
[
|
||||||
|
body('shopName').notEmpty().isString().withMessage(_sr.fa.required.name),
|
||||||
|
body('shopNumber').notEmpty().isString().withMessage(_sr.fa.required.store_number),
|
||||||
|
body('shopAddress').notEmpty().isString().withMessage(_sr.fa.required.address),
|
||||||
|
body('birthDate').notEmpty().isString().withMessage(_sr.fa.required.date),
|
||||||
|
],
|
||||||
|
checkValidations(validationResult),
|
||||||
|
async (req, res) => {
|
||||||
|
const { shopName, shopNumber, shopAddress, birthDate, profilePic } = req.body;
|
||||||
|
const repeated = await RequestGPS.findOne({ userId: req.user_id })
|
||||||
|
if (repeated) {
|
||||||
|
res400(res, "شما قبلا درخواست ثبت کرده اید")
|
||||||
|
} else {
|
||||||
|
const request = await RequestGPS.create({
|
||||||
|
shopName,
|
||||||
|
shopNumber,
|
||||||
|
shopAddress,
|
||||||
|
birthDate,
|
||||||
|
profilePic,
|
||||||
|
userId: req.user_id,
|
||||||
|
})
|
||||||
|
res.status(201).json({ msg: 'درخواست شما با موفقیت ثبت شد', date: request })
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.getAllRequest = [
|
||||||
|
async (req, res) => {
|
||||||
|
const data = await RequestGPS.find({}).sort({ status: 1 })
|
||||||
|
res.status(200).json(data)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports.getOneRequest = [
|
||||||
|
[
|
||||||
|
param('id').notEmpty().isMongoId().withMessage('این ایدی اشتباه است')
|
||||||
|
],
|
||||||
|
checkValidations(validationResult),
|
||||||
|
async (req, res) => {
|
||||||
|
const data = await RequestGPS.findById(req.params.id).populate('userId')
|
||||||
|
res.status(200).json(data)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.changeStatus = [
|
||||||
|
[
|
||||||
|
param('status').notEmpty().isString().withMessage('این استاتوس اشتباه است'),
|
||||||
|
param('id').notEmpty().isMongoId().withMessage('این ایدی اشتباه است')
|
||||||
|
],
|
||||||
|
checkValidations(validationResult),
|
||||||
|
async (req, res) => {
|
||||||
|
switch (req.params.status) {
|
||||||
|
case "accept": {
|
||||||
|
const data = await RequestGPS.findByIdAndUpdate(req.params.id,
|
||||||
|
{
|
||||||
|
status:1
|
||||||
|
},
|
||||||
|
{ new: true })
|
||||||
|
const userData = await User.findByIdAndUpdate(
|
||||||
|
data.userId,
|
||||||
|
{
|
||||||
|
shopName: data.shopName,
|
||||||
|
shopNumber: data.shopNumber,
|
||||||
|
shopAddress: data.shopAddress,
|
||||||
|
birthDate: data.birthDate,
|
||||||
|
},
|
||||||
|
{ new: true}
|
||||||
|
)
|
||||||
|
res.status(200).json({ msg: 'با موفقیت به روز شد', data:userData })
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "reject": {
|
||||||
|
const data = await RequestGPS.findByIdAndUpdate(req.params.id,
|
||||||
|
{
|
||||||
|
status:2
|
||||||
|
},
|
||||||
|
{ new: true })
|
||||||
|
|
||||||
|
res.status(200).json({ msg: 'با موفقیت به روز شد', data })
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
res.status(400).json({ msg: 'این استاتوس اشتباه است' })
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1238,179 +1238,6 @@ module.exports.update_user_by_admin = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
/// //////////////////////////////////////////////////////////////////// authentication
|
|
||||||
|
|
||||||
/// //////// Login
|
|
||||||
|
|
||||||
module.exports.webLogin = [
|
|
||||||
[
|
|
||||||
body('username')
|
|
||||||
.isLength({ min: 4 })
|
|
||||||
.withMessage(_faSr.min_char.min4)
|
|
||||||
.bail()
|
|
||||||
.if((value, { req }) => {
|
|
||||||
return req.body.password && req.body.password.length >= 4
|
|
||||||
})
|
|
||||||
.custom((value, { req }) => {
|
|
||||||
return User.findOne({
|
|
||||||
$or: [{ email: value.toLowerCase().trim() }, { national_code: value }, { username: value }]
|
|
||||||
}).then(user => {
|
|
||||||
if (!user) return Promise.reject(_faSr.not_found.password)
|
|
||||||
else return true
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
|
|
||||||
body('password')
|
|
||||||
.notEmpty()
|
|
||||||
.withMessage(_faSr.required.password)
|
|
||||||
.bail()
|
|
||||||
.isLength({ min: 4 })
|
|
||||||
.withMessage(_faSr.min_char.min4),
|
|
||||||
|
|
||||||
body('remember_me')
|
|
||||||
.exists()
|
|
||||||
.withMessage(_faSr.required.remember_me)
|
|
||||||
.bail()
|
|
||||||
.isBoolean()
|
|
||||||
.withMessage(_faSr.format.boolean)
|
|
||||||
],
|
|
||||||
checkValidations(validationResult),
|
|
||||||
async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { username, password } = req.body
|
|
||||||
const user = await User.findOne({
|
|
||||||
$or: [{ email: username.toLowerCase().trim() }, { national_code: username }, { username }]
|
|
||||||
})
|
|
||||||
if (!user) throw new Error('err')
|
|
||||||
const passwordMatch = await bcrypt.compare(password, user.password)
|
|
||||||
if (!passwordMatch) throw new Error('err')
|
|
||||||
const token = await jwt.sign({ _id: user._id }, secretKey, {
|
|
||||||
expiresIn: req.body.remember_me ? '30d' : '7d'
|
|
||||||
})
|
|
||||||
user.token = token
|
|
||||||
await user.save()
|
|
||||||
return res.json({ token })
|
|
||||||
} catch (err) {
|
|
||||||
return res.status(422).json({
|
|
||||||
validation: { username: { msg: _faSr.not_found.password } }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
module.exports.appLogin = [
|
|
||||||
[
|
|
||||||
body('username')
|
|
||||||
.isLength({ min: 4 })
|
|
||||||
.withMessage(_faSr.min_char.min4)
|
|
||||||
.bail()
|
|
||||||
.if((value, { req }) => {
|
|
||||||
return req.body.password && req.body.password.length >= 4
|
|
||||||
})
|
|
||||||
.custom((value, { req }) => {
|
|
||||||
return User.findOne({
|
|
||||||
$or: [{ email: value.toLowerCase().trim() }, { national_code: value }]
|
|
||||||
}).then(user => {
|
|
||||||
if (!user) return Promise.reject(_faSr.not_found.password)
|
|
||||||
else return true
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
|
|
||||||
body('password')
|
|
||||||
.notEmpty()
|
|
||||||
.withMessage(_faSr.required.password)
|
|
||||||
.bail()
|
|
||||||
.isLength({ min: 4 })
|
|
||||||
.withMessage(_faSr.min_char.min4)
|
|
||||||
],
|
|
||||||
checkValidations(validationResult),
|
|
||||||
async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { username, password } = req.body
|
|
||||||
const user = await User.findOne({
|
|
||||||
$or: [{ email: username.toLowerCase().trim() }, { national_code: username }]
|
|
||||||
})
|
|
||||||
if (!user) throw new Error('err')
|
|
||||||
|
|
||||||
const passwordMatch = await bcrypt.compare(password, user.password)
|
|
||||||
if (!passwordMatch) throw new Error('err')
|
|
||||||
|
|
||||||
const token = await jwt.sign({ _id: user._id }, secretKey, {
|
|
||||||
expiresIn: '60d'
|
|
||||||
})
|
|
||||||
user.appToken = token
|
|
||||||
await user.save()
|
|
||||||
return res.json({ token })
|
|
||||||
} catch (err) {
|
|
||||||
return res.status(422).json({
|
|
||||||
validation: { username: { msg: _faSr.not_found.password } }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
/// //////// logout
|
|
||||||
module.exports.webLogout = [
|
|
||||||
async (req, res) => {
|
|
||||||
try {
|
|
||||||
const token = req.headers?.authorization
|
|
||||||
if (!token) throw new Error('err')
|
|
||||||
|
|
||||||
const user = await User.findOne({ token })
|
|
||||||
if (!user) throw new Error('err')
|
|
||||||
|
|
||||||
user.token = null
|
|
||||||
await user.save()
|
|
||||||
|
|
||||||
return res.json({ message: _faSr.response.logged_out })
|
|
||||||
} catch (err) {
|
|
||||||
return res.status(401).json({ message: _faSr.response.not_logged_in })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
module.exports.appLogout = [
|
|
||||||
async (req, res) => {
|
|
||||||
try {
|
|
||||||
const token = req.headers?.authorization
|
|
||||||
if (!token) throw new Error('err')
|
|
||||||
|
|
||||||
const user = await User.findOne({ appToken: token })
|
|
||||||
if (!user) throw new Error('err')
|
|
||||||
|
|
||||||
user.appToken = null
|
|
||||||
await user.save()
|
|
||||||
|
|
||||||
return res.json({ message: _faSr.response.logged_out })
|
|
||||||
} catch (err) {
|
|
||||||
return res.status(401).json({ message: _faSr.response.not_logged_in })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
/// //////// get user
|
|
||||||
module.exports.getUser = [
|
|
||||||
async (req, res) => {
|
|
||||||
try {
|
|
||||||
const token = req.headers?.authorization
|
|
||||||
if (!token) throw new Error('err')
|
|
||||||
|
|
||||||
const decoded = jwt.verify(token, secretKey)
|
|
||||||
if (!decoded) throw new Error('err')
|
|
||||||
|
|
||||||
const user = await User.findById(decoded?._id).select(
|
|
||||||
'-token -appToken -emailConfirmationKey -mobileConfirmationKey -password -resetPassToken'
|
|
||||||
)
|
|
||||||
return res.json({ user })
|
|
||||||
} catch (err) {
|
|
||||||
console.log('🚀 ~ file: userController.js ~ line 1070 ~ err', err)
|
|
||||||
return res.status(401).json({ message: 'unauthenticated' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
module.exports.updateUserByAdmin = [
|
module.exports.updateUserByAdmin = [
|
||||||
[
|
[
|
||||||
body('first_name')
|
body('first_name')
|
||||||
@@ -1595,3 +1422,177 @@ module.exports.updateUserByAdmin = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/// //////////////////////////////////////////////////////////////////// authentication
|
||||||
|
|
||||||
|
/// //////// Login
|
||||||
|
|
||||||
|
module.exports.webLogin = [
|
||||||
|
[
|
||||||
|
body('username')
|
||||||
|
.isLength({ min: 4 })
|
||||||
|
.withMessage(_faSr.min_char.min4)
|
||||||
|
.bail()
|
||||||
|
.if((value, { req }) => {
|
||||||
|
return req.body.password && req.body.password.length >= 4
|
||||||
|
})
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
return User.findOne({
|
||||||
|
$or: [{ email: value.toLowerCase().trim() }, { national_code: value }, { username: value }]
|
||||||
|
}).then(user => {
|
||||||
|
if (!user) return Promise.reject(_faSr.not_found.password)
|
||||||
|
else return true
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('password')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.password)
|
||||||
|
.bail()
|
||||||
|
.isLength({ min: 4 })
|
||||||
|
.withMessage(_faSr.min_char.min4),
|
||||||
|
|
||||||
|
body('remember_me')
|
||||||
|
.exists()
|
||||||
|
.withMessage(_faSr.required.remember_me)
|
||||||
|
.bail()
|
||||||
|
.isBoolean()
|
||||||
|
.withMessage(_faSr.format.boolean)
|
||||||
|
],
|
||||||
|
checkValidations(validationResult),
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { username, password } = req.body
|
||||||
|
const user = await User.findOne({
|
||||||
|
$or: [{ email: username.toLowerCase().trim() }, { national_code: username }, { username }]
|
||||||
|
})
|
||||||
|
if (!user) throw new Error('err')
|
||||||
|
const passwordMatch = await bcrypt.compare(password, user.password)
|
||||||
|
if (!passwordMatch) throw new Error('err')
|
||||||
|
const token = await jwt.sign({ _id: user._id }, secretKey, {
|
||||||
|
expiresIn: req.body.remember_me ? '30d' : '7d'
|
||||||
|
})
|
||||||
|
user.token = token
|
||||||
|
await user.save()
|
||||||
|
return res.json({ token })
|
||||||
|
} catch (err) {
|
||||||
|
return res.status(422).json({
|
||||||
|
validation: { username: { msg: _faSr.not_found.password } }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports.appLogin = [
|
||||||
|
[
|
||||||
|
body('username')
|
||||||
|
.isLength({ min: 4 })
|
||||||
|
.withMessage(_faSr.min_char.min4)
|
||||||
|
.bail()
|
||||||
|
.if((value, { req }) => {
|
||||||
|
return req.body.password && req.body.password.length >= 4
|
||||||
|
})
|
||||||
|
.custom((value, { req }) => {
|
||||||
|
return User.findOne({
|
||||||
|
$or: [{ email: value.toLowerCase().trim() }, { national_code: value }]
|
||||||
|
}).then(user => {
|
||||||
|
if (!user) return Promise.reject(_faSr.not_found.password)
|
||||||
|
else return true
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
body('password')
|
||||||
|
.notEmpty()
|
||||||
|
.withMessage(_faSr.required.password)
|
||||||
|
.bail()
|
||||||
|
.isLength({ min: 4 })
|
||||||
|
.withMessage(_faSr.min_char.min4)
|
||||||
|
],
|
||||||
|
checkValidations(validationResult),
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { username, password } = req.body
|
||||||
|
const user = await User.findOne({
|
||||||
|
$or: [{ email: username.toLowerCase().trim() }, { national_code: username }]
|
||||||
|
})
|
||||||
|
if (!user) throw new Error('err')
|
||||||
|
|
||||||
|
const passwordMatch = await bcrypt.compare(password, user.password)
|
||||||
|
if (!passwordMatch) throw new Error('err')
|
||||||
|
|
||||||
|
const token = await jwt.sign({ _id: user._id }, secretKey, {
|
||||||
|
expiresIn: '60d'
|
||||||
|
})
|
||||||
|
user.appToken = token
|
||||||
|
await user.save()
|
||||||
|
return res.json({ token })
|
||||||
|
} catch (err) {
|
||||||
|
return res.status(422).json({
|
||||||
|
validation: { username: { msg: _faSr.not_found.password } }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
/// //////// logout
|
||||||
|
module.exports.webLogout = [
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
const token = req.headers?.authorization
|
||||||
|
if (!token) throw new Error('err')
|
||||||
|
|
||||||
|
const user = await User.findOne({ token })
|
||||||
|
if (!user) throw new Error('err')
|
||||||
|
|
||||||
|
user.token = null
|
||||||
|
await user.save()
|
||||||
|
|
||||||
|
return res.json({ message: _faSr.response.logged_out })
|
||||||
|
} catch (err) {
|
||||||
|
return res.status(401).json({ message: _faSr.response.not_logged_in })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports.appLogout = [
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
const token = req.headers?.authorization
|
||||||
|
if (!token) throw new Error('err')
|
||||||
|
|
||||||
|
const user = await User.findOne({ appToken: token })
|
||||||
|
if (!user) throw new Error('err')
|
||||||
|
|
||||||
|
user.appToken = null
|
||||||
|
await user.save()
|
||||||
|
|
||||||
|
return res.json({ message: _faSr.response.logged_out })
|
||||||
|
} catch (err) {
|
||||||
|
return res.status(401).json({ message: _faSr.response.not_logged_in })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
/// //////// get user
|
||||||
|
module.exports.getUser = [
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
const token = req.headers?.authorization
|
||||||
|
if (!token) throw new Error('err')
|
||||||
|
|
||||||
|
const decoded = jwt.verify(token, secretKey)
|
||||||
|
if (!decoded) throw new Error('err')
|
||||||
|
|
||||||
|
const user = await User.findById(decoded?._id).select(
|
||||||
|
'-token -appToken -emailConfirmationKey -mobileConfirmationKey -password -resetPassToken'
|
||||||
|
)
|
||||||
|
return res.json({ user })
|
||||||
|
} catch (err) {
|
||||||
|
console.log('🚀 ~ file: userController.js ~ line 1070 ~ err', err)
|
||||||
|
return res.status(401).json({ message: 'unauthenticated' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
/// ////////////////////////////////////////////////////////////////////////// GPS Section
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
const mongoose = require('mongoose')
|
||||||
|
|
||||||
|
const RequestSchema = mongoose.Schema({
|
||||||
|
userId:{
|
||||||
|
type:String,
|
||||||
|
ref:'User'
|
||||||
|
},
|
||||||
|
shopName:String,
|
||||||
|
shopNumber:String,
|
||||||
|
shopAddress:String,
|
||||||
|
birthDate:String,
|
||||||
|
status:{
|
||||||
|
type:Number,
|
||||||
|
enum:[
|
||||||
|
0, // Pending
|
||||||
|
1, // Accepted
|
||||||
|
2 // Rejected
|
||||||
|
],
|
||||||
|
default:0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = mongoose.model('RequestGPS', RequestSchema)
|
||||||
@@ -55,11 +55,19 @@ const UserSchema = mongoose.Schema({
|
|||||||
password: String,
|
password: String,
|
||||||
|
|
||||||
// for GPS
|
// for GPS
|
||||||
|
profilePic:{
|
||||||
|
type:String,
|
||||||
|
default:"noPic"
|
||||||
|
},
|
||||||
shopName:String,
|
shopName:String,
|
||||||
shopNumber:String,
|
shopNumber:String,
|
||||||
shopAddress:String,
|
shopAddress:String,
|
||||||
birthDate:String,
|
birthDate:String,
|
||||||
walletBalance:String,
|
walletBalance:{
|
||||||
|
type:Number,
|
||||||
|
min:0,
|
||||||
|
default:0
|
||||||
|
},
|
||||||
cardBank:[BankSchema],
|
cardBank:[BankSchema],
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
module.exports.res404 = (res, err) => {
|
module.exports.res404 = (res, err) => {
|
||||||
return res.status(404).json({ message: err })
|
return res.status(404).json({ message: err })
|
||||||
}
|
}
|
||||||
|
module.exports.res400 = (res, err) => {
|
||||||
|
return res.status(404).json({ message: err })
|
||||||
|
}
|
||||||
module.exports.res406 = (res, err) => {
|
module.exports.res406 = (res, err) => {
|
||||||
return res.status(406).json({ message: err })
|
return res.status(406).json({ message: err })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,5 +114,9 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
name: 'برند ها',
|
name: 'برند ها',
|
||||||
value: 'brands'
|
value: 'brands'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'جی پی اس',
|
||||||
|
value: 'gps'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ module.exports._sr = {
|
|||||||
company_name: 'درصورتی که شخص حقوقی هستید، نام کمپانی را وارد کنید',
|
company_name: 'درصورتی که شخص حقوقی هستید، نام کمپانی را وارد کنید',
|
||||||
username: 'نام کاربری را وارد کنید',
|
username: 'نام کاربری را وارد کنید',
|
||||||
phone_number: 'شماره تماس را وارد کنید',
|
phone_number: 'شماره تماس را وارد کنید',
|
||||||
|
store_number: 'شماره تماس مغازه را وارد کنید',
|
||||||
password: 'پسورد را وارد کنید',
|
password: 'پسورد را وارد کنید',
|
||||||
birthdate: 'تاریخ تولد را وارد کنید',
|
birthdate: 'تاریخ تولد را وارد کنید',
|
||||||
// addressing validations
|
// addressing validations
|
||||||
|
|||||||
@@ -26,9 +26,15 @@ const smsBroadcastController = require('../controllers/smsBroadcastController')
|
|||||||
const surveyController = require('../controllers/surveyController')
|
const surveyController = require('../controllers/surveyController')
|
||||||
const complaintController = require('../controllers/complaintController')
|
const complaintController = require('../controllers/complaintController')
|
||||||
const brandController = require('../controllers/brandController')
|
const brandController = require('../controllers/brandController')
|
||||||
|
const requestController = require('../controllers/GPS.Request')
|
||||||
|
|
||||||
|
|
||||||
/// //////////////////////////////////////////////////////// routes
|
/// //////////////////////////////////////////////////////// routes
|
||||||
|
/// ///////////// GPS
|
||||||
|
router.get('/gps/request',hasPermission('gps'), requestController.getAllRequest)
|
||||||
|
router.get('/gps/request/:id',hasPermission('gps'), requestController.getOneRequest)
|
||||||
|
router.patch('/gps/request/:id/:status',hasPermission('gps'), requestController.changeStatus)
|
||||||
|
|
||||||
/// ///////////// survey
|
/// ///////////// survey
|
||||||
router.get('/surveys',hasPermission('surveys'), surveyController.getAllForAdmin)
|
router.get('/surveys',hasPermission('surveys'), surveyController.getAllForAdmin)
|
||||||
router.get('/surveys/:id',hasPermission('surveys'), surveyController.getOneForAdmin)
|
router.get('/surveys/:id',hasPermission('surveys'), surveyController.getOneForAdmin)
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ const representationController = require('../controllers/representationControlle
|
|||||||
const transactionDraftsController = require('../controllers/transactionDraftsController')
|
const transactionDraftsController = require('../controllers/transactionDraftsController')
|
||||||
const transactionController = require('../controllers/transactionController')
|
const transactionController = require('../controllers/transactionController')
|
||||||
const surveyController = require('../controllers/surveyController')
|
const surveyController = require('../controllers/surveyController')
|
||||||
|
const requestController = require('../controllers/GPS.Request')
|
||||||
|
|
||||||
|
/// // GPS
|
||||||
|
router.post('/gps/request', requestController.gpsRequest)
|
||||||
|
|
||||||
/// // profile
|
/// // profile
|
||||||
router.put('/update_profile', userController.update_user)
|
router.put('/update_profile', userController.update_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user