PageRenderTime 45ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/app/models/User.scala

https://bitbucket.org/edofic/poster
Scala | 29 lines | 17 code | 7 blank | 5 comment | 0 complexity | 64557979ee44982dc920d1a2bdccb5ec MD5 | raw file
  1. package models
  2. import play.api.Play.current
  3. import com.novus.salat._
  4. import com.novus.salat.dao._
  5. import com.novus.salat.global._
  6. import com.mongodb.casbah.Imports._
  7. import se.radley.plugin.salat._
  8. import utils.Passwords
  9. /**
  10. * User: andraz
  11. * Date: 12/6/12
  12. * Time: 10:13 PM
  13. */
  14. case class User(username: String, password: EncryptedPassword)
  15. object User{
  16. object dao extends SalatDAO[User, ObjectId](collection = mongoCollection("users"))
  17. def create(username: String, password: String){
  18. dao insert User(username, Passwords.encrypt(password))
  19. }
  20. def find(username: String): Option[User] =
  21. dao findOne MongoDBObject("username" -> username)
  22. }