*/
class GetLikesAjaxPage(webInterface: WebInterface) : JsonPage("getLikes.ajax", webInterface) {
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun createJsonObject(request: FreenetRequest) =
when (request.parameters["type"]) {
class GetLinkedElementAjaxPage(webInterface: WebInterface, private val elementLoader: ElementLoader, private val linkedElementRenderFilter: LinkedElementRenderFilter):
JsonPage("getLinkedElement.ajax", webInterface) {
+ override val needsFormPassword = false
+
override fun createJsonObject(request: FreenetRequest): JsonReturnObject =
request.httpRequest.getParam("elements", "[]").asJson()
.map(JsonNode::asText)
}
}
- override fun needsFormPassword() = false
override fun requiresLogin() = false
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
*/
class GetNotificationsAjaxPage(webInterface: WebInterface) : JsonPage("getNotifications.ajax", webInterface) {
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun requiresLogin() = false
override fun createJsonObject(request: FreenetRequest) =
*/
class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Template) : LoggedInJsonPage("getPost.ajax", webInterface) {
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
request.parameters["post"]
*/
class GetReplyAjaxPage(webInterface: WebInterface, private val template: Template) : LoggedInJsonPage("getReply.ajax", webInterface) {
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
request.parameters["reply"]
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun requiresLogin() = false
private fun SoneOptions.toJsonOptions() = jsonObject {
this.timeZone = timeZone
}
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun requiresLogin() = false
override fun createJsonObject(request: FreenetRequest) =
*/
class GetTranslationAjaxPage(webInterface: WebInterface) : JsonPage("getTranslation.ajax", webInterface) {
- override fun needsFormPassword() = false
+ override val needsFormPassword = false
override fun requiresLogin() = false
override fun createJsonObject(request: FreenetRequest) =
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)
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)) {
private val page = object : JsonPage("path.html", webInterface) {
- override fun needsFormPassword() = this@JsonPageBaseTest.needsFormPassword
+ override val needsFormPassword get() = this@JsonPageBaseTest.needsFormPassword
override fun createJsonObject(request: FreenetRequest) =
pageResponse().also { pageCallCounter.incrementAndGet() }
@Test
fun `page needs form password`() {
- assertThat(page.needsFormPassword(), equalTo(needsFormPassword))
+ assertThat(page.needsFormPassword, equalTo(needsFormPassword))
}
@Test