MongoMetaRecord MegaProtoUser Password not hashed when signing in
I am using the MegaProtoUser in my Lift/Scala app for managing users.
On my running app, I can sign up with a new user normally and he remains singed in just after sign up. After I log out and try logging in with the same user name and password, the app complains that the username/password is invalid.
I checked the mongo database entry for the password field and found that the password is hashed.
If I copy and paste the the hashed password the mongo database directly in the password field of the web app, the user is logged in. Password in the database looks like this: oqGR/cR+phb7fpSOL1Bpi8mtV...
Code for model.User.scala:
/**
* The singleton that has methods for accessing the database
*/
object User extends User with MongoMetaRecord[User] with MetaMegaProtoUser[User] {
override def screenWrap = Full(<lift:surround with="default" at="content">
<lift:bind /></lift:surround>)
// define the order fields will appear in forms and output
override def fieldOrder = List(id, firstName, lastName, email,
locale, timezone, password)
// comment this line out to require email validations
override def skipEmailValidation = true
}
/**
* An O-R mapped "User" class that includes first name, last name, password and we add a "Personal Essay" to it
*/
class User private() extends MongoRecord[User] with MegaProtoUser[User] {
def meta = User // what's the "meta" server
protected def userFromStringId(id: String): Box[User] = meta.find(id)
protected def findUserByUniqueId(id: String): Box[User] = {
var searchListHeadOption = meta.findAll("_id",id).headOption
searchListHeadOption match {
case Some(x) => Full(x)
case None => return Empty
}
}
/**
* Given an username (probably email address), find the user
*/
protected def findUserByEmail(email: String): Box[User] = {
var searchListHeadOption = meta.findAll("email",email).headOption
searchListHeadOption match {
case Some(x) => Full(x)
case None => return Empty
}
}
protected def findUserByUserName(email: String): Box[User] = findUserByEmail(email)
override def valUnique(errorMsg: => String)(emailValue: String) = {
meta.findAll("email",emailValue) match {
case Nil => Nil
case usr :: Nil if (usr.id == id) => Nil
case _ => List(FieldError(email, "The email should be unique"))
}
}
// define an additional field for a personal essay
}
When logging in, the entered password is matched with the hashed password from the db. I am kind of stuck at this point.
Any help would be appreciated.开发者_运维百科
Thanks!
I saw similar Lift issue regarding Record's PasswordField open. Hope it helps!
精彩评论