我已将 Play-Authenticate 模块集成到我的 Play 2.0.4 项目中。我的项目有两种视图,传统的网络视图和移动视图。当应用程序注销时,它只是返回到索引页面。在路由表中,我看到注销功能指向此:
GET /logout com.feth.play.module.pa.controllers.Authenticate.logout
模块代码如下所示:
public static Result logout() {
noCache(response());
return PlayAuthenticate.logout(session());
}
应用程序的工作方式是有一个 main.scala.html 文件,其中包含 Web 应用程序所需的 css/js 链接,以及一个 mobile_main.scala.html 页面,其中包含移动模板内容使用的 css/js。我遇到的问题是,当我退出应用程序(移动或网络)时,我会被重定向到网络应用程序的索引 - index.scala.html。无论如何,是否可以更改此设置,以便在适当的时候可以将我定向到移动索引页面?
Thanks
编辑:这也适用于应用程序成功登录后返回的页面。
好吧,进一步查看后,我将问题追溯到全局.java。我想我需要改变下面的方法来解决我的问题。这样我就可以根据可能传递的参数加载不同的页面。
@Override
public Call login() {
// Your login page
return routes.Application.login();
}
@Override
public Call afterAuth() {
// The user will be redirected to this page after authentication
// if no original URL was saved
return routes.Application.index();
}
@Override
public Call afterLogout() {
return routes.Application.index();
}
一种方法是将您的状态保存在会话中,例如您可以有两种状态:mobile session
and web session
然后在重定向之前验证这一点
if mobile session then redirect mobile index else redirect index
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)