Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidating session causes exception #107

Closed
vaadin-kim opened this issue Dec 22, 2014 · 2 comments
Closed

Invalidating session causes exception #107

vaadin-kim opened this issue Dec 22, 2014 · 2 comments
Labels

Comments

@vaadin-kim
Copy link

Implementing a logout functionality properly requires invalidating the user's session upon a logout event. This way, we guarantee that any potential user resources bound to a session are not accidentally leaked to the next user.

Vaadin's wiki recommends invalidating the session and then redirecting the user to a login page.

VaadinService.getCurrentRequest().getWrappedSession().invalidate();
// Redirect to avoid keeping the removed UI open in the browser
getUI().getPage().setLocation(getLogoutPageLocation());

The second line causes an exception:

java.lang.IllegalStateException: Current VaadinSession is not open
    at org.vaadin.spring.internal.VaadinUIScope$VaadinSessionBeanStoreRetrievalStrategy.getVaadinSession(VaadinUIScope.java:115)
    at org.vaadin.spring.internal.VaadinUIScope$VaadinSessionBeanStoreRetrievalStrategy.getUIStore(VaadinUIScope.java:121)
    at org.vaadin.spring.internal.VaadinUIScope$VaadinSessionBeanStoreRetrievalStrategy.getBeanStore(VaadinUIScope.java:148)
    at org.vaadin.spring.internal.VaadinUIScope.getBeanStore(VaadinUIScope.java:94)
    at org.vaadin.spring.internal.VaadinUIScope.get(VaadinUIScope.java:70)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:336)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
....
@peholmst peholmst added the bug label Dec 23, 2014
@LukaszByczynski
Copy link
Contributor

With following code:

public void logout() {
   getPage.setLocation("http://www.google.com");
   push();

   // Close the VaadinServiceSession
   getSession.close();

   // Invalidate underlying session instead if login info is stored there
   VaadinService.getCurrentRequest.getWrappedSession.invalidate();
}

I put this code into UI class and it's works correctly.

@gjrtimmer
Copy link
Collaborator

Logout and redirecting the user to the login page is now handle by the springSecurityFilterChain.

Fixed #149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants