X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonPage.kt;h=9ea1d1da2b3ad2b198a020241e8e6d96d7378a11;hb=4bf90851f9e7a8f31d4f58f4f74dc46d8e4ddec8;hp=6ba842f9ab900f22b92fefc36af0d990d072aaca;hpb=ea53134b4fc925265c9d58d22c650c4e4b7e685d;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt index 6ba842f..9ea1d1d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt @@ -19,11 +19,12 @@ abstract class JsonPage(private val path: String, protected val webInterface: We private val objectMapper = ObjectMapper() private val sessionProvider: SessionProvider = webInterface + protected val core = webInterface.core override fun getPath() = path override fun isPrefixPage() = false - open fun needsFormPassword() = true + open val needsFormPassword = true open fun requiresLogin() = true protected fun createSuccessJsonObject() = JsonReturnObject(true) @@ -34,10 +35,10 @@ abstract class JsonPage(private val path: String, protected val webInterface: We sessionProvider.getCurrentSone(toadletContext, createSession) override fun handleRequest(request: FreenetRequest, response: Response): Response { - if (webInterface.core.preferences.isRequireFullAccess && !request.toadletContext.isAllowedFullAccess) { + if (core.preferences.isRequireFullAccess && !request.toadletContext.isAllowedFullAccess) { return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString()) } - if (needsFormPassword() && request.parameters["formPassword"] != webInterface.formPassword) { + if (needsFormPassword && request.parameters["formPassword"] != webInterface.formPassword) { return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString()) } if (requiresLogin() && (sessionProvider.getCurrentSone(request.toadletContext, false) == null)) {