Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LoginView with PolymerTemplate not recognizing error parameter

I have a LoginView which I basically copied from the bakery starter project.

When I run the bakery app and try to login with wrong credentials, there appears an additional div with an error message.

However, this error message div does not appear in my view. I have since adapted the template to our Corporate Design, but I can remember that this issue already existed when the two files LoginView.java and login-view.html were still exact copies from the bakery app. I double checked that .error is not just hidden by my own css - the div.error is not existing in the DOM.

Debugging the LoginView when visiting /login?error (visiting login?error=true is the same) shows that it does not recognize any queryParameters! --> Why?


My App debugged: debugging screenshot


Bakery App debugged: debugging screenshot 2


My (Spring) Security Configuration is the same too where the login is concerned:

.and()
.formLogin()
.loginPage(("/login")).permitAll()
.loginProcessingUrl("/login")
.failureUrl("/login?error")

Edit: as asked for in the comments, I'll add the relevant part of the template. However, the error is 100% not in the template - as I can see with debugging that the error occurs already in the LoginView.java in the afterNavigation method.

<dom-module id="login-view">
  <template>
    <style include="shared-styles">
        .....
    </style>
        .....
            <template is="dom-if" if="[[error]]">
              <div class="error">
                <iron-icon icon="vaadin:exclamation-circle-o" class="error__icon"></iron-icon>
                <p class="error__text">
                  Der Benutzername und/oder das Passwort stimmt nicht. Bitte überprüfe deine Angaben und versuche es erneut.
                </p>
              </div>
            </template>
      ....
  </template>

  <script>
    class LoginView extends Polymer.GestureEventListeners(Polymer.Element) {
        static get is() {
            return 'login-view';
        }

        static get properties() {
            return {
                error: {
                    type: Boolean,
                    value: false
                }
            };
        }
        ......
    }
    window.customElements.define(LoginView.is, LoginView);
  </script>
</dom-module>
like image 521
kscherrer Avatar asked Feb 07 '19 09:02

kscherrer


1 Answers

While the question is quite old, it seems like the issue was somehow related to to the liberty server. There probably was something that prevented (?) the usage of the ?error query parameter in this case, as the same code works on other servers.

If the issue still persists and can be reproduced in project that can be shared, you should create an issue to the vaadin/spring repository. The LoginView implementation should not made based on a PolymerTemplate anymore, as there is a server side Java integrations that can be used, like the LoginOverlay component. Also starting from Vaadin 20, there is a Spring security configuration class VaadinWebSecurityConfigurerAdapter which provides helpers for setting up Spring security with Vaadin apps. There is more details on the documentation.

like image 172
Pekka Hyvönen Avatar answered Nov 15 '22 23:11

Pekka Hyvönen