在liferay中自动登录时处理身份验证失败

在liferay中自动登录时处理身份验证失败,liferay,velocity,Liferay,Velocity,我有一个主题,我有一个弹出窗口,要求登录凭据 它有两个字段,登录id和密码,后跟一个提交按钮 <div class="x"> <div class="y"> <aui:input name="login" id="login" class="z" type="text" placeholder="Email" showRequiredL

我有一个主题,我有一个弹出窗口,要求登录凭据

它有两个字段,登录id和密码,后跟一个提交按钮

<div class="x">
    <div class="y">
        <aui:input name="login" id="login" class="z"
        type="text" placeholder="Email"                                               showRequiredLabel="<%=false%>" label="" value="<%=login%>">
        </aui:input>
    </div>
</div> 

<div class="x">
    <div class="y">
        <aui:input name="password" id="Password"
        class="z" type="password" placeholder="Password"
        showRequiredLabel="<%=false%>" label="" value="<%=password%>">
        </aui:input>
    </div>
</div>

<div class="x">
    <div class="y">
        <aui:button-row>
            <aui:button type="submit" class="btn z"
            value="Log in" id=z/>
            </aui:button-row>
        </div>
</div>

<script>
jQuery(document).ready(function($) {


$('#z').click(function(){
var textBoxEmail= $('#login').val();
var textBoxPassword=  $('#Password').val(); 
var redirecturl="/home";

var url = Liferay.ThemeDisplay.getPortalURL()+"/c/portal/login?login=" + textBoxEmail + "&password=" +textBoxPassword+"&rememberMe=false&redirect=" + redirecturl;
$("#loginDetails").attr('action',url);
document.getElementById('loginDetails').submit();

}
});

</script>

jQuery(文档).ready(函数($){
$('#z')。单击(函数(){
var textBoxEmail=$('#login').val();
var textBoxPassword=$('#Password').val();
var redirecturl=“/home”;
var url=Liferay.ThemeDisplay.getPortalURL()+“/c/portal/login?login=“+textBoxEmail+”&password=“+textBoxPassword+”&rememberMe=false&redirect=“+redirecturl;
$(“#loginDetails”).attr('action',url);
document.getElementById('loginDetails').submit();
}
});
此项登录为肯定情况,但如果输入的密码或电子邮件不正确,则会显示

“此网页不可用

错误\u内容\u解码\u失败”

我希望在发送登录详细信息的同一页面中显示失败消息,或者如果身份验证失败,我希望将其重定向到某个URL


我使用的是liferay-6.2-ce-ga3,主题是在velocity中设计的。

你可以重定向到
/c/portal/login?redirect=currenturl
,重定向到当前url。如果你想定制更多内容,编写钩子是另一种选择。

所以在你开始之前,我会从架构的角度质疑你的设计。我在Liferay中,登录功能实际上是它自己的portlet(称为登录portlet)。修改登录功能的正确方法是通过一个钩子。但是,为了更直接地回答您的问题,我会修改您的代码(大部分代码取自Liferay的login.jsp)


var password=A.one(“#password”);
如果(密码){
密码打开('keypress',函数(事件){
Liferay.Util.showCapsLock(事件'passwordCapsLockSpan');
});
}

我同意,使用登录挂钩或使用登录前和登录后筛选器的身份验证管道。重定向可以通过筛选器完成

<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL">
    <portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL>

<aui:form action="<%= loginURL %>" autocomplete='<%= PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off" %>' cssClass="sign-in-form" method="post" name="fm">
    <aui:input name="saveLastPath" type="hidden" value="<%= false %>" />
    <aui:input name="redirect" type="hidden" value="<%= redirect %>" />
    <aui:input name="doActionAfterLogin" type="hidden" value="<%= portletName.equals(PortletKeys.FAST_LOGIN) ? true : false %>" />

    <%
    String loginLabel = null;
    String authType = portletPreferences.getValue("authType", StringPool.BLANK);

    if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
        loginLabel = "email-address";
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
        loginLabel = "screen-name";
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
        loginLabel = "id";
    }
    %>

    <aui:input autoFocus="<%= windowState.equals(LiferayWindowState.EXCLUSIVE) || windowState.equals(WindowState.MAXIMIZED) %>" cssClass="clearable" label="<%= loginLabel %>" name="login" showRequiredLabel="<%= false %>" type="text" value="<%= login %>">
        <aui:validator name="required" />
    </aui:input>

    <aui:input name="password" showRequiredLabel="<%= false %>" type="password" value="<%= password %>">
        <aui:validator name="required" />
    </aui:input>

    <span id="<portlet:namespace />passwordCapsLockSpan" style="display: none;"><liferay-ui:message key="caps-lock-is-on" /></span>

    <aui:button-row>
        <aui:button type="submit" value="sign-in" />
    </aui:button-row>
</aui:form>

<aui:script use="aui-base">
    var password = A.one('#<portlet:namespace />password');

    if (password) {
        password.on('keypress', function(event) {
            Liferay.Util.showCapsLock(event, '<portlet:namespace />passwordCapsLockSpan');
        });
    }
</aui:script>