Notif system

This commit is contained in:
Mr Swift
2024-09-28 23:00:10 +03:30
parent 8f63b82236
commit b1f792f493
8 changed files with 130 additions and 0 deletions
+10
View File
@@ -7,6 +7,8 @@ const { checkValidations } = require('../plugins/controllersHelperFunctions')
const UserGPS = require('../models/GPS.User')
const { generateRandomDigits
} = require('../plugins/controllersHelperFunctions')
const Notification = require('../models/GPS.Notif')
module.exports.login_with_pass = [
[
body('username')
@@ -55,6 +57,10 @@ module.exports.login_with_pass = [
})
user.token = token
await user.save()
await Notification.create({
userID:user._id,
content:"test"
})
return res.status(200).json({ token })
} catch (err) {
return res.status(422).json({
@@ -90,6 +96,10 @@ module.exports.login_with_otp = [
})
user.otp = generateRandomDigits(6)
user.save()
await Notification.create({
userID:user._id,
content:"test"
})
return res.status(200).json({ token })
}