Skip to content

Commit

Permalink
add catch for when user does not setup mail object
Browse files Browse the repository at this point in the history
  • Loading branch information
moeiscool committed Jun 16, 2017
1 parent e08b400 commit 87bd4ab
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,14 @@ app.post('/',function (req,res){
r.details.acceptedMachines={}
}
if(!r.details.acceptedMachines[req.body.machineID]){
req.complete=function(){
s.factorAuth[r.ke][r.uid].info=req.resp;
clearTimeout(s.factorAuth[r.ke][r.uid].expireAuth)
s.factorAuth[r.ke][r.uid].expireAuth=setTimeout(function(){
s.deleteFactorAuth(r)
},1000*60*15)
res.render("factor",{$user:req.resp})
}
if(!s.factorAuth[r.ke]){s.factorAuth[r.ke]={}}
if(!s.factorAuth[r.ke][r.uid]){
s.factorAuth[r.ke][r.uid]={key:s.nid()}
Expand All @@ -2497,17 +2505,15 @@ app.post('/',function (req,res){
};
nodemailer.sendMail(r.mailOptions, (error, info) => {
if (error) {
console.log(error)
return ;
s.systemLog('MAIL ERROR : You must set up conf.json with the mail object or this feature will not work. skipping 2-Factor Authentication this time.',error)
req.fn()
return
}
req.complete()
});
}else{
req.complete()
}
s.factorAuth[r.ke][r.uid].info=req.resp;
clearTimeout(s.factorAuth[r.ke][r.uid].expireAuth)
s.factorAuth[r.ke][r.uid].expireAuth=setTimeout(function(){
s.deleteFactorAuth(r)
},1000*60*15)
res.render("factor",{$user:req.resp})
}else{
req.fn()
}
Expand Down

0 comments on commit 87bd4ab

Please sign in to comment.