Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Accounts.validateLoginAttempt(function(info){
- var user = info.user;
- var failAttemp = user.profile.loginFaileAttempt;
- if(failAttemp == 3){
- console.log('you need to contact the admin!')
- return false;
- }else{
- if(Meteor.Error == 'Incorrect password '){
- // incremnt the fail attempts
- failAttemp++;
- console.log(failAttemp);
- }
- }
- return true;
- // success login set to 0
- failAttemp = 0;
- });
- Accounts.validateLoginAttempt(function(info){
- var user = info.user;
- if (!user)
- return false;
- var failAttempt = 0;
- if (user.profile)
- failAttempt = user.profile.loginFaileAttempt;
- var loginAllowed = false;
- if(info.error && info.error.error == 403){
- if(failAttempt >= 3) {
- console.log('you need to contact the admin!');
- throw new Meteor.Error(403, 'you need to contact the admin!');
- }
- // increment the fail attempts
- failAttempt++;
- console.log(failAttempt);
- loginAllowed = false;
- } else {
- // success login set to 0
- failAttempt = 0;
- loginAllowed = true;
- }
- Meteor.users.update({_id: user._id}, {$set: {'profile.loginFaileAttempt': failAttempt}});
- return loginAllowed;
- });
Add Comment
Please, Sign In to add comment