Add base JSON page that requires a logged-in user
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / ajax / LoggedInJsonPage.kt
diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
new file mode 100644 (file)
index 0000000..acf1d73
--- /dev/null
@@ -0,0 +1,20 @@
+package net.pterodactylus.sone.web.ajax
+
+import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.web.WebInterface
+import net.pterodactylus.sone.web.page.FreenetRequest
+
+/**
+ * Base JSON page for all pages that require the user to be logged in.
+ */
+open class LoggedInJsonPage(path: String, webInterface: WebInterface) : JsonPage(path, webInterface) {
+
+       final override fun requiresLogin() = true
+
+       final override fun createJsonObject(request: FreenetRequest) =
+                       createJsonObject(getCurrentSone(request.toadletContext)!!, request)
+
+       open protected fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
+                       createErrorJsonObject("not-implemented")
+
+}