update: add shafafiat pages

This commit is contained in:
mahyargdz
2024-11-19 14:01:47 +03:30
parent 1c89bc5f08
commit 256924dd3a
15 changed files with 329 additions and 26 deletions
+14
View File
@@ -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);
}
},
];
+3 -2
View File
@@ -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 {
+1
View File
@@ -4,6 +4,7 @@ const mongoosePaginate = require("mongoose-paginate-v2");
const LoggerSchema = mongoose.Schema({
LastLogin: String,
user: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
ip: { type: String, default: null },
});
LoggerSchema.plugin(mongoosePaginate);
+15
View File
@@ -0,0 +1,15 @@
const { model } = require("mongoose");
const { Schema } = require("mongoose");
const ShafafSchema = Schema(
{
title: { type: String },
icon: { type: String },
link: { type: String },
},
{
timestamps: true,
}
);
module.exports = model("Shafaf", ShafafSchema);