2013-09-16 84 views
3

如何實現和MySQL數據庫的SecureSocial(最新快照版本)插件?如何實施Slick + MySQL + SecureSocial?

我認爲我完全配置了一切。

我有我的用戶模型類是這樣的:

package models.auth 

    import securesocial.core._ 
    import scala.slick.driver.MySQLDriver._ 

    case class User(identityId: IdentityId, 
        firstName: String, 
        lastName: String, 
        fullName: String, 
        email: Option[String], 
        avatarUrl: Option[String], 
        authMethod: AuthenticationMethod, 
        oAuth1Info: Option[OAuth1Info] = None, 
        oAuth2Info: Option[OAuth2Info] = None, 
        passwordInfo: Option[PasswordInfo] = None) extends Identity 

    object User { 
     def apply(i: Identity): User = { 
      User(
       i.identityId, 
       i.firstName, 
       i.lastName, 
       i.fullName, 
       i.email, 
       i.avatarUrl, 
       i.authMethod, 
       i.oAuth1Info, 
       i.oAuth2Info, 
       i.passwordInfo 
     ) 
    } 
} 

object Users extends Table[User]("user") { 

    def userId = column[Long]("id", O.PrimaryKey, O.AutoInc) 

    def providerId = column[String]("providerId") 

    def email = column[Option[String]]("email") 

    def firstName = column[String]("firstName") 

    def lastName = column[String]("lastName") 

    def fullName = column[String]("fullName") 

    def avatarUrl = column[Option[String]]("avatarUrl") 

    def authMethod = column[AuthenticationMethod]("authMethod") 

    // oAuth 1 
    def token = column[Option[String]]("token") 

    def secret = column[Option[String]]("secret") 

    // oAuth 2 
    def accessToken = column[Option[String]]("accessToken") 

    def tokenType = column[Option[String]]("tokenType") 

    def expiresIn = column[Option[Int]]("expiresIn") 

    def refreshToken = column[Option[String]]("refreshToken") 

    // passwordInfo 
    def hasher = column[String]("hasher") 

    def password = column[String]("password") 

    def salt = column[String]("salt") 

} 

我有什麼未來呢?使用哪些導入和方法來實現? 文檔非常差。

回答

2

您必須通過擴展UserServicePlugin對象來實現UserService特性。

該文件不是那麼差:UserService Documentation

SecureSocial依靠UserService的實現來處理所有與保存/查找用戶相關的操作。

+0

好的。沒關係。正如我所看到的,我必須像插件提供者一樣使用它。是? – mrzepinski

+0

是的。將此插件添加到'play.plugins'。 – maba