Add page that always requires a logged-in user
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / FollowSonePage.kt
index 5069d16..cf5bcee 100644 (file)
@@ -1,5 +1,6 @@
 package net.pterodactylus.sone.web.pages
 
+import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
@@ -10,21 +11,19 @@ import net.pterodactylus.util.template.TemplateContext
  * This page lets the user follow another Sone.
  */
 class FollowSonePage(template: Template, webInterface: WebInterface):
-               SoneTemplatePage("followSone.html", template, "Page.FollowSone.Title", webInterface, true) {
+               LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
+       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
                if (freenetRequest.isPOST) {
                        freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+"))
                                        .map { it to webInterface.core.getSone(it) }
                                        .filterNot { it.second == null }
                                        .forEach { sone ->
-                                               webInterface.core.followSone(freenetRequest.currentSone, sone.first)
+                                               webInterface.core.followSone(currentSone, sone.first)
                                                webInterface.core.markSoneKnown(sone.second)
                                        }
                        throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
                }
        }
 
-       private val FreenetRequest.currentSone get() = sessionProvider.getCurrentSone(toadletContext)
-
 }