hook - 重定向到 liferay 登录页面

标签 hook liferay liferay-6

我正在创建一个钩子(Hook)来检查用户登录情况,并且根据某些参数,它将被重定向到一个或另一个自定义页面。

我正在这样做:

门户.属性

#Gestion evento login
login.events.post=com.liferay.portal.events.AccionLogin
auth.forward.by.last.path=true

Action 类

public class AccionLogin extends Action {

    @Override
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
        try {
            doRun(request, response);
        } catch (Exception e) {
            throw new ActionException(e);
        }
    }
    protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception {

        HttpSession sesion = request.getSession();

        User usuarioLogin = PortalUtil.getUser(request);

        // Recupero la lista de roles
        ArrayList<Role> roles = UtilRoles.getIntExtRol();

        // Compruebo si el usuario pertenece al grupo
        if (UtilLdap.esGrupo(request, usuarioLogin.getScreenName())) {
            Constantes._log.info("El usuario es Interno en el Ldap vector. Gestiono su rol");
            UtilRoles.setRoleIfNotHave(usuarioLogin, roles, Constantes.INTERNOS);
            sesion.setAttribute(WebKeys.LAST_PATH, UtilUrls.generaLasthPath(request, Constantes.INTERNOS));
        } else {
            Constantes._log.info("El usuario es externo en el Ldap vector. Gestiono su rol");
            UtilRoles.setRoleIfNotHave(usuarioLogin, roles, Constantes.EXTERNOS);
            sesion.setAttribute(WebKeys.LAST_PATH, UtilUrls.generaLasthPath(request, Constantes.EXTERNOS));
        }
    }
}

这个方法:

sesion.setAttribute(WebKeys.LAST_PATH, UtilUrls.generaLasthPath(request, Constantes.EXTERNOS));

这样做:

return new LastPath(StringPool.BLANK,Constantes.GROUPINTRANET+Constantes.SEPARADOR+Constantes.INICIOINTERNOS,
             new HashMap<String, String[]>());

生成group/intranet/pageforexterns,与实习生相同,但当我登录时,出现cookie错误和重定向错误。

我做错了什么?

谢谢

最佳答案

您只需通过 LastPath lastPath=(LastPath)session.getAttribute(WebKeys.LAST_PATH); 获取 LastPath 对象,而不是创建 LastPath 的新实例。并使用lastPath.setPath(PATH)来避免任何错误。

关于hook - 重定向到 liferay 登录页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14557879/

相关文章:

java - 在Liferay搜索容器中显示来自不同数据库表的数据: Liferay

Liferay门户: UTF-8 encoding

c# - 如何 Hook 全局 WM_APPCOMMAND 消息?

php - WordPress Hook

java - 无密码登录 Liferay 用户

mysql - 无法在 mysql DB liferay 中保存笑脸

java - 无法通过 JSON 按类别查找 liferay 文章

c++ - 未调用 dll Hook 函数

java - Liferay Portlet部署

java - 具有非常大表的 Liferay 6 持久 session