From 02b429ae28a89151cd75227485e6956433e50c65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 25 Jul 2012 22:16:54 +0200 Subject: [PATCH] Add logout page. --- .../demoscenemusic/page/LogoutPage.java | 61 ++++++++++++++++++++++ src/main/resources/templates/logout | 0 src/main/webapp/WEB-INF/web.xml.template | 4 ++ 3 files changed, 65 insertions(+) create mode 100644 src/main/java/net/pterodactylus/demoscenemusic/page/LogoutPage.java create mode 100644 src/main/resources/templates/logout diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/LogoutPage.java b/src/main/java/net/pterodactylus/demoscenemusic/page/LogoutPage.java new file mode 100644 index 0000000..95ab3ea --- /dev/null +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/LogoutPage.java @@ -0,0 +1,61 @@ +/* + * DemosceneMusic - LogoutPage.java - Copyright © 2012 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.demoscenemusic.page; + +import net.pterodactylus.demoscenemusic.core.Core; +import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.template.TemplateContextFactory; +import net.pterodactylus.util.web.RedirectException; + +/** + * Page that logs out the current user. + * + * @author David ‘Bombe’ Roden + */ +public class LogoutPage extends BasePage { + + /** + * Creates a new logout page. + * + * @param core + * The core + * @param templateContextFactory + * The template context factory + * @param template + * The template to render + */ + public LogoutPage(Core core, TemplateContextFactory templateContextFactory, Template template) { + super(core, templateContextFactory, template, "logout"); + } + + // + // BASEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(TemplateContext templateContext, ServletRequest request) throws RedirectException { + super.processTemplate(templateContext, request); + request.getServletRequest().getSession().removeAttribute("currentUser"); + throw new RedirectException("."); + } + +} diff --git a/src/main/resources/templates/logout b/src/main/resources/templates/logout new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/WEB-INF/web.xml.template b/src/main/webapp/WEB-INF/web.xml.template index aa22191..98e0d4d 100644 --- a/src/main/webapp/WEB-INF/web.xml.template +++ b/src/main/webapp/WEB-INF/web.xml.template @@ -48,6 +48,10 @@ net.pterodactylus.demoscenemusic.page.LoginPage + logout + net.pterodactylus.demoscenemusic.page.LogoutPage + + openid net.pterodactylus.demoscenemusic.page.OpenIdPage -- 2.7.4