jeudi 21 mai 2015

Show auth error on xhtml login page

I have configured authentication using wildfly security-domains. Everything works if credintials are valid. I want to show error message on login.xhtml page when username or password are wrong. How can i do this? I'm using primefaces for pre valdiation(empty fields).

My login.xhtml page:

<h:body
    style="background: url(resources/background.png);   background-repeat: no-repeat; background-attachment: fixed; background-position: center; ">
    <div id="loginDiv" style="margin: 0 auto;">
        <h:form id="login"
            onsubmit="document.getElementById('login').action='j_security_check';"
            prependId="false">

            <p:growl id="growl" sticky="true" showDetail="true" life="3000" />

            <p:dialog id="loginDial" header="Login page"
                widgetVar="loginDialog" width="400" height="130" visible="true"
                closable="false" draggable="false" resizable="false">
                <h:panelGrid columns="2" style="margin: 0 auto;">
                    <p:outputLabel for="j_username" value="Username:" />
                    <p:inputText id="j_username" name="j_username" required="true" />
                    <p:outputLabel for="j_password" value="Password:" />
                    <p:password id="j_password" name="j_password" required="true" />
                    <p:outputLabel value=" " />
                    <p:commandButton id="submit" value="Login" ajax="false" />
                </h:panelGrid>
            </p:dialog>
        </h:form>
    </div>
</h:body>

Do you have any ideas how to show message?

i found something like this:

<login-config>
        <auth-method>FORM</auth-method>
        <realm-name>LDAPAuth realm</realm-name>
        <form-login-config>
            <form-login-page>/login.xhtml</form-login-page>
            <form-error-page>/login.xhtml?failed=true</form-error-page>
        </form-login-config>
    </login-config>

But i don't see failed=true in url on failed login :/

Aucun commentaire:

Enregistrer un commentaire