我正在网上浏览以查找某种教程,但找不到它。我想我可以使用securesocial提供的twitter示例
例子:
def onlyAdmin = SecuredAction(WithAuth("admin")) { implicit request =>
Ok("You could see this since you are admin")
}
case class WithAuth(role: String) extends Authorization {
def isAuthorized(user: Identity) = {
val existingDbUser = User.findUserByProviderUserId(user)
existingDbUser.hasRole(role)
}
User.findUserByProviderUserId(user)
调用数据库来查找存储的用户及其角色。我不希望每次都调用 db 并使用Identity
.
你会如何解决这个问题?