播放身份验证登出重定向 [英] Play-Authenticate logout redirect

查看:80
本文介绍了播放身份验证登出重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Play 2.0.4项目中集成了Play-Authenticate模块.我的项目有两个视图,一个常规的Web视图和一个移动视图.当应用程序注销时,它仅返回到索引页面.在路由表中,我看到注销功能指向此:

I have integrated the Play-Authenticate module in my Play 2.0.4 project. There are two views to my project, a conventional web view and a mobile view. When the application logs out it just returns to the index page. In the routes table I see that the logout functionality points towards this:

GET     /logout                             com.feth.play.module.pa.controllers.Authenticate.logout

在模块代码中如下所示:

Which looks like this in the module code:

public static Result logout() {
    noCache(response());

    return PlayAuthenticate.logout(session());
}

应用程序的工作方式是存在一个main.scala.html文件,其中包含Web应用程序所需的css/js链接,以及一个mobile_main.scala.html页,其中包含移动模板的内容使用的css/js .我遇到的问题是,当我退出应用程序(移动或Web)时,我被重定向到Web应用程序的索引-index.scala.html.无论如何,是否可以更改此设置,以便在适当的时候将我定向到移动索引页面?

The way the application works is there is a main.scala.html file with the css/js links that the web application needs and a mobile_main.scala.html page with the css/js that the contents of the mobile templates use. The problem I am having is that when I sign out of the application (either mobile or web) I get redirected to the index of the web application - index.scala.html. Is there anyway to change this so that I can be directed to the mobile index page when appropriate?

谢谢

这也适用于成功登录后应用程序返回的页面.

This also applies to the page the application returns to after a successful login.

好一点,再看一遍,我将问题追溯到 Global.java .我认为我需要更改以下方法来解决我的问题.这样我就可以根据传递的参数加载不同的页面.

Ok after looking a bit further I traced the problem back to Global.java. I think I need to change the methods below to solve my problem. So that I can load a different page depending on an argument passed perhaps.

        @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 sessionweb session,然后在重定向之前的状态

One of the way is to save your state in the session, for example you can have two states: mobile session and web session and then verify this in condition before redirecting

if mobile session then redirect mobile index else redirect index

这篇关于播放身份验证登出重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆