X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FLogoutPage.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FLogoutPage.java;h=a4730ad238f2a7776e53795f0a82bc8646cd5e00;hb=a744a3dccfe730a5fa4f5d21cb3506eb02d25323;hp=0000000000000000000000000000000000000000;hpb=be893c81154fc559faa094d5440941db33d293e6;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java new file mode 100644 index 0000000..a4730ad --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java @@ -0,0 +1,69 @@ +/* + * FreenetSone - LogoutPage.java - Copyright © 2010 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.sone.web; + +import net.pterodactylus.util.template.Template; +import freenet.clients.http.ToadletContext; + +/** + * Logs a user out. + * + * @author David ‘Bombe’ Roden + */ +public class LogoutPage extends SoneTemplatePage { + + /** + * @param template + * The template to render + * @param webInterface + * The Sone web interface + */ + public LogoutPage(Template template, WebInterface webInterface) { + super("logout.html", template, "Page.Logout.Title", webInterface); + } + + // + // TEMPLATEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(Request request, Template template) throws RedirectException { + setCurrentSone(request.getToadletContext(), null); + throw new RedirectException("index.html"); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean requiresLogin() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isEnabled(ToadletContext toadletContext) { + return getCurrentSone(toadletContext) != null; + } + +}