services: {
type: Object,
},
'services.$': {
type: Object,
},
'services.$.password': {
type: String,
custom: function () {
//updateId.get() is check it is insert of update
if(updateId.get() == undefined ){
}else{
//for update code check password is match or not
var digest = Package.sha.SHA256(this.value);
return Meteor.call('checkPassword', digest,updateId.get()._id, function(err, result) {
if (result) {
console.log('the passwords match!');
}else{
console.log('the passwords DONT match!');
return "passwordMismatch";
}
});
}
}
},
Meteor.methods({
checkPassword: function(digest,user) {
check(digest, String);
if (digest) {
var password = {digest: digest, algorithm: 'sha-256'};
var result = Accounts._checkPassword(Meteor.users.findOne({_id: user}), password);
return result.error == null;
} else {
return false;
}
}
});
Please tell me when i am wrong
for validation
here console right but not return error