-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkauthorization.js
25 lines (25 loc) · 1004 Bytes
/
checkauthorization.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const Users=require('./models/User')
const checkauthorization=(req,res,next)=>{
if(req.body.id!==undefined)
{
Users.findOne({_id:req.body.id,Authorize:true},(err,doc)=>{
if(err) return res.json({message:"Failed",err})
else
{
if(doc!==null)
{
// const updatespecific= User.updateOne({email:req.body.email},{$set:{Authorize:{$eq:true}}})
//res.json(updatespecific)
Users.findOneAndUpdate({_id:req.body.id},{Authorize:true},{new:true},(error,data)=>{
if(error)return res.json({message:"Failed",error})
else{
return res.json({messageL:"User Login",user:data})
}
})
}
else
{
return res.json("Not authorized")
}
}})}}
module.exports=checkauthorization