From: David ‘Bombe’ Roden Date: Wed, 25 Jul 2012 20:16:54 +0000 (+0200) Subject: Add logout page. X-Git-Url: https://git.pterodactylus.net/?p=demoscenemusic.git;a=commitdiff_plain;h=02b429ae28a89151cd75227485e6956433e50c65 Add logout page. --- 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