我想在 play framework 1.2.4 中的 controllers.securesocial 中自定义 authenticate(),因为我需要在登录到使用 play 框架的应用程序之前验证一些事情。
问问题
326 次
1 回答
0
您可以尝试在您的自定义类扩展中验证您的东西,这里UserServicePlugin
可以使用 scala 和 java 中的示例:
class MyUserService(application: Application) extends UserServicePlugin(application) {
/**
* Finds a user that maches the specified id
*
* @param id the user id
* @return an optional user
*/
def find(id: UserId):Option[Identity] = {
// implement me
}
/**
* Finds a user by email and provider id.
*
* Note: If you do not plan to use the UsernamePassword provider just provide en empty
* implementation.
*
* @param email - the user email
* @param providerId - the provider id
* @return
*/
def findByEmailAndProvider(email: String, providerId: String):Option[Identity] =
{
// implement me
}
/**
* Saves the user. This method gets called when a user logs in.
* This is your chance to save the user information in your backing store.
* @param user
*/
def save(user: Identity) {
// implement me
}
/**
* Saves a token. This is needed for users that
* are creating an account in the system instead of using one in a 3rd party system.
*
* Note: If you do not plan to use the UsernamePassword provider just provide en empty
* implementation
*
* @param token The token to save
* @return A string with a uuid that will be embedded in the welcome email.
*/
def save(token: Token) = {
// implement me
}
/**
* Finds a token
*
* Note: If you do not plan to use the UsernamePassword provider just provide en empty
* implementation
*
* @param token the token id
* @return
*/
def findToken(token: String): Option[Token] = {
// implement me
}
/**
* Deletes a token
*
* Note: If you do not plan to use the UsernamePassword provider just provide en empty
* implementation
*
* @param uuid the token id
*/
def deleteToken(uuid: String) {
// implement me
}
/**
* Deletes all expired tokens
*
* Note: If you do not plan to use the UsernamePassword provider just provide en empty
* implementation
*
*/
def deleteExpiredTokens() {
// implement me
}
}
这些方法在您的 play 应用程序的整个登录过程生命周期中使用 securesocial 插件调用。
于 2013-08-26T06:55:10.810 回答