I am trying to insert username and encrypted password pairs into database table using squeryl ORM framework. My code basically looks like the following:
class SHA1(e: StringExpression[String], m:OutMapper[String]) extends FunctionNode[String]("sha1", Some(m), Seq(e)) with StringExpression[String]
def sha1(e:StringExpression[String])(implicit m:OutMapper[String]) = new SHA1(e,m)
transaction{
val foo = TestUser.userTable insert User("test@domain.com", sha1("password"))
}
But this does not work. I got an error saying:
type mismatch; found : controllers.SHA1 required: String Error occurred in an application involving default arguments.
There is a limit to the magic that Squeryl can perform here. Your model class takes a String value for password, and you are passing it a value of type SHA1 (the value that is returned from the sha1 function). The scala compiler isn't going to allow that. There are a couple of options here:
To hash the password before you insert it, look at java.security.MessageDigest
and see this answer.