LT-97: Add requireRegexValidation and requireStrongPasswords properties under passwordOptions which is under passwordOptions.
- requireRegexValidation toggles whether or not password validation is controlled by regular expression - requireStrongPasswords toggles whether password validation is controlled by zxcvbn package LT-104: User account shall be locked after 5 failed attempts - "failedAttemptsLimit" property which is under passwordOptions in ActiveEntry configuration object sets number of failed attempts count to lock user account, it is set 5 as default LT-99: Passwords shall use password history of 6 - "passwordHistoryCount" property which is under passwordOptions in ActiveEntry configuration object sets count of last passwords that is not used to reset password - Show error messages in changePassword template - Make signIn button disabled if inputs are not validated
This commit is contained in:
1 parent
24e615da1e
commit
eb32e1771f
15 files changed
+250
-49
No files matched your search
@@ -3,10 +3,74 @@ Meteor.methods({
|
||||
console.log('Initializing Users', Meteor.users.find().fetch());
|
||||
|
||||
},
|
||||
|
||||
dropEntryUsers: function (){
|
||||
console.log('Drop Users', Meteor.users.find().fetch());
|
||||
Meteor.users.find().forEach(function(user){
|
||||
Meteor.users.remove({_id: user._id});
|
||||
});
|
||||
},
|
||||
|
||||
insertHashedPassword: function(passwordParameters) {
|
||||
var hashedPassword = passwordParameters[0];
|
||||
var passwordHistoryCount = passwordParameters[1];
|
||||
|
||||
var userId = Meteor.userId();
|
||||
var previousPasswords = Meteor.users.findOne({_id: userId}).previousPasswords;
|
||||
if (previousPasswords) {
|
||||
if (previousPasswords.length == passwordHistoryCount) {
|
||||
// Remove oldest password
|
||||
var ascSortedPasswords = _.sortBy(previousPasswords, function(previousPassword){ return previousPassword.createdAt; });
|
||||
ascSortedPasswords.splice(0, 1);
|
||||
previousPasswords = ascSortedPasswords;
|
||||
}
|
||||
|
||||
previousPasswords.push({hashedPassword: hashedPassword, createdAt: new Date()});
|
||||
Meteor.users.update({_id: userId}, {$set: {previousPasswords: previousPasswords}});
|
||||
} else {
|
||||
Meteor.users.update({_id: userId}, {$set: {previousPasswords: [{hashedPassword: hashedPassword, createdAt: new Date(), select: false}]}});
|
||||
}
|
||||
},
|
||||
|
||||
checkPasswordExistence: function(hashedPassword) {
|
||||
var previousPasswords = Meteor.users.find({_id: Meteor.userId()}).fetch()[0].previousPasswords;
|
||||
for(var i=0; i< previousPasswords.length; i++) {
|
||||
var recordedHashedPassword = previousPasswords[i].hashedPassword;
|
||||
if (recordedHashedPassword == hashedPassword) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
getFailedAttemptsCount: function(emailAddress) {
|
||||
return Meteor.users.findOne({"emails.address": emailAddress}).failedPasswordAttempts || 0;
|
||||
},
|
||||
|
||||
updateFailedAttempts: function(failedAttemptsParameters) {
|
||||
var emailAddress = failedAttemptsParameters[0];
|
||||
var failedAttemptsLimit = failedAttemptsParameters[1];
|
||||
var failedAttemptCount = Meteor.users.findOne({"emails.address": emailAddress}).failedPasswordAttempts || 0;
|
||||
if (failedAttemptCount == failedAttemptsLimit) {
|
||||
return failedAttemptCount;
|
||||
} else {
|
||||
if (failedAttemptCount == 4) {
|
||||
// Locked user account
|
||||
Meteor.users.update({"emails.address": emailAddress}, {$set: {"profile.isLocked": true, failedPasswordAttempts: failedAttemptCount + 1}});
|
||||
} else if (failedAttemptCount < 4) {
|
||||
Meteor.users.update({"emails.address": emailAddress}, {$set: {failedPasswordAttempts: failedAttemptCount + 1}});
|
||||
}
|
||||
}
|
||||
|
||||
return failedAttemptCount + 1;
|
||||
},
|
||||
|
||||
resetFailedAttempts: function(emailAddress) {
|
||||
Meteor.users.update({"emails.address": emailAddress}, {$set: {failedPasswordAttempts: 0}});
|
||||
},
|
||||
|
||||
updatePasswordCreatedDate: function() {
|
||||
Meteor.users.update({_id: Meteor.userId()}, {$set: {"services.password.createdAt": new Date()}});
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user