Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

As a User I want to be able to logout and clear my cookies

  • Loading branch information...
commit d9b35803ea0321dc5e80f80d480a6af527a457fa 1 parent 59cb50d
@tdziurko authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/main/java/pl/tomaszdziurko/wicket/view/HomePage.java
View
10 src/main/java/pl/tomaszdziurko/wicket/view/HomePage.java
@@ -6,6 +6,9 @@
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import pl.tomaszdziurko.wicket.UserSession;
+import pl.tomaszdziurko.wicket.WicketApplication;
+import pl.tomaszdziurko.wicket.service.CookieService;
+import pl.tomaszdziurko.wicket.service.SessionProvider;
public class HomePage extends BasePage {
private static final long serialVersionUID = 1L;
@@ -18,7 +21,12 @@ public HomePage(final PageParameters parameters) {
Link<Void> logoutLink = new Link<Void>("logout") {
@Override
public void onClick() {
- UserSession.get().invalidateNow();
+ CookieService cookieService = WicketApplication.get().getCookieService();
+ cookieService.removeCookieIfPresent(getRequest(), getResponse(), SessionProvider.REMEMBER_ME_LOGIN_COOKIE);
+ cookieService.removeCookieIfPresent(getRequest(), getResponse(), SessionProvider.REMEMBER_ME_PASSWORD_COOKIE);
+
+ UserSession.get().setUser(null);
+ UserSession.get().invalidate();
}
};
logoutLink.setVisible(UserSession.get().userLoggedIn());
Please sign in to comment.
Something went wrong with that request. Please try again.