使用for-comprehension循环遍历Scala中的String并生成一个字符映射和一个表示该字符在字符串中的次数的整数是什么好方法?
def mapString(s: String): Map[Char, Int] = {
for(c<-s) ...
}
答案 0 :(得分:0)
exports.localAuth = function (username, password) {
return db.User.findOne({ username: username }).exec()
.then(function (result){
if(result){
var hash = result._doc.passwordHash;
if(!hash){
console.warn("User " + username + " has no password set");
return null;
}
console.log(bcrypt.compareSync(password, hash));
if (bcrypt.compareSync(password, hash)) {
return result;
} else {
return null;
}
} else {
return null;
}
},
function(reason){
console.error("Failed to login: " + reason);
}
);
};