2017-05-31 4 views
0

私は、ログイン資格情報を要求するポップアップがあるテーマを持っています。自動ログインでの生存期間の認証失敗の処理

2つのフィールド、ログイン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> 

正の場合のために、このログインが、それは

を表示incorrecet入力されたパスワードや電子メールの場合は

"このウェブページには、利用可能な

ERR_CONTENT_DECODING_FAILEDではありません"

私はログインの詳細を送信している場所から同じページに失敗メッセージを表示したいのですが、それを一部にリダイレクトしたい認証に失敗した場合のURL。

私はliferay-6.2-ce-ga3を使用しています。テーマは速度で設計されています。

答えて

0

/c/portal/login?redirect=currenturlにリダイレクトすると、現在のURLにリダイレクトされます。もっとカスタマイズしたい場合は、フックを書くことは別のオプションです。

0

あなたが始める前に、私は建築の観点からあなたのデザインに疑問を呈します。 Liferayでは、ログイン機能は実際には独自のポートレット(ログインポートレットと呼ばれます)です。ログイン機能を変更する正しい方法は、フック経由です。しかし、あなたの質問にもっと直接答えるために、私はあなたのコードをそのように変更します(これはほとんどがLiferayのlogin.jspから取られています)。

<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> 
0

私は同意すると、ログインフックまたはログイン前および後のフィルタを使用する認証パイプラインに同意します。リダイレクトはフィルタから行うことができます。

関連する問題