♻️ Add freenet client interface
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / LogoutPage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.web.*
6 import net.pterodactylus.sone.web.page.*
7 import net.pterodactylus.util.template.*
8 import javax.inject.*
9
10 /**
11  * Logs a user out.
12  */
13 @MenuName("Logout")
14 @ToadletPath("logout.html")
15 class LogoutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
16                 LoggedInPage("Page.Logout.Title", webInterface, loaders, templateRenderer) {
17
18         override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
19                 setCurrentSone(soneRequest.toadletContext, null)
20                 redirectTo("index.html")
21         }
22
23         override fun isEnabled(soneRequest: SoneRequest): Boolean =
24                         if (soneRequest.core.preferences.requireFullAccess && !soneRequest.toadletContext.isAllowedFullAccess) {
25                                 false
26                         } else
27                                 getCurrentSone(soneRequest.toadletContext) != null && soneRequest.core.localSones.size != 1
28
29 }