Update GPS.Auth.js
This commit is contained in:
@@ -94,8 +94,13 @@ module.exports.login_with_otp = [
|
|||||||
const token = await jwt.sign({ _id: user._id }, secretKey, {
|
const token = await jwt.sign({ _id: user._id }, secretKey, {
|
||||||
expiresIn: req.body.remember_me ? '30d' : '7d'
|
expiresIn: req.body.remember_me ? '30d' : '7d'
|
||||||
})
|
})
|
||||||
|
// eslint-disable-next-line eqeqeq
|
||||||
|
if (user?.lastIP && user?.lastIP != req.ip) {
|
||||||
|
SMS([user.mobile_number], "test")
|
||||||
|
}
|
||||||
user.otp = generateRandomDigits(6)
|
user.otp = generateRandomDigits(6)
|
||||||
user.lastIP = req.ip
|
user.lastIP = req.ip
|
||||||
|
user.token = token
|
||||||
user.save()
|
user.save()
|
||||||
return res.status(200).json({ token })
|
return res.status(200).json({ token })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user