本文整理汇总了Scala中com.mohiva.play.silhouette.api.LogoutEvent类的典型用法代码示例。如果您正苦于以下问题:Scala LogoutEvent类的具体用法?Scala LogoutEvent怎么用?Scala LogoutEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogoutEvent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: SignOutController
//设置package包名称以及导入依赖的类
package controllers
import com.google.inject.Inject
import com.mohiva.play.silhouette.api.{LogoutEvent, Silhouette}
import play.api.mvc.{AbstractController, ControllerComponents}
import utils.JsonResults
import utils.auth.DefaultEnv
class SignOutController @Inject() (
components: ControllerComponents,
silhouette: Silhouette[DefaultEnv]
) extends AbstractController(components) {
def submit = silhouette.SecuredAction.async { implicit request =>
silhouette.env.eventBus.publish(
LogoutEvent(request.identity, request)
)
silhouette.env.authenticatorService.discard(
request.authenticator,
Ok(JsonResults.success("User signed out"))
)
}
}
开发者ID:edgarmueller,项目名称:plog-backend,代码行数:24,代码来源:SignOutController.scala
示例2: Application
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.Inject
import com.mohiva.play.silhouette.api.{Environment, LogoutEvent, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import forms._
import models.User
import play.api.i18n.MessagesApi
import scala.concurrent.Future
class Application @Inject()(val messagesApi: MessagesApi, val env: Environment[User, SessionAuthenticator])
extends Silhouette[User, SessionAuthenticator] {
def index = UserAwareAction { implicit request =>
Ok(views.html.index(request.identity))
}
def dashboard = SecuredAction { implicit request =>
Ok(views.html.dashboard(request.identity))
}
def signIn = UserAwareAction.async { implicit request =>
request.identity match {
case Some(_) => Future.successful(Redirect(routes.Application.index()))
case None => Future.successful(Ok(views.html.signIn(SignInForm.form)))
}
}
def signUp = SecuredAction { implicit request =>
Ok(views.html.signUp(SignUpForm.form))
}
def signOut = SecuredAction.async { implicit request =>
val result = Redirect(routes.Application.index())
env.eventBus.publish(LogoutEvent(request.identity, request, request2Messages))
env.authenticatorService.discard(request.authenticator, result)
}
}
开发者ID:wjglerum,项目名称:bamboesmanager,代码行数:41,代码来源:Application.scala
注:本文中的com.mohiva.play.silhouette.api.LogoutEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论