update: add shafafiat pages
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const Shafafiat = require("../models/shafafiat");
|
||||
|
||||
module.exports.getAll = [
|
||||
async (req, res) => {
|
||||
try {
|
||||
const shafafiat = await Shafafiat.find({});
|
||||
return res.json({
|
||||
data: shafafiat,
|
||||
});
|
||||
} catch (error) {
|
||||
return res500(res, error.message);
|
||||
}
|
||||
},
|
||||
];
|
||||
@@ -165,7 +165,7 @@ module.exports.otp = [
|
||||
// .withMessage(_sr["fa"].min_char.min4),
|
||||
],
|
||||
async (req, res) => {
|
||||
console.log('body', req.body)
|
||||
console.log("body", req.body);
|
||||
try {
|
||||
const errors = validationResult(req);
|
||||
if (!errors.isEmpty())
|
||||
@@ -183,6 +183,7 @@ module.exports.otp = [
|
||||
ttl: (cacheService.getTtl(`OTP:LOGIN:${phone}`) - Date.now()) / 1000,
|
||||
});
|
||||
const otp = crypto.randomInt(10000, 99999);
|
||||
console.log("==> otp :", otp);
|
||||
const message = `کد ورود شما ${otp} میباشد. استانداری لغو11`;
|
||||
/** save otp in cache */
|
||||
cacheService.set(`OTP:LOGIN:${phone}`, otp, 120);
|
||||
@@ -264,7 +265,7 @@ module.exports.verifyOtp = [
|
||||
if (logger) {
|
||||
await Logger.findOneAndUpdate(
|
||||
{ user: user._id },
|
||||
{ $set: { LastLogin: new Date() } },
|
||||
{ $set: { LastLogin: new Date(), ip: req.ip } },
|
||||
{ new: true }
|
||||
);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user