*/
class BookmarkAjaxPage(webInterface: WebInterface) : JsonPage("bookmark.ajax", webInterface) {
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["post"].emptyToNull
*/
class DismissNotificationAjaxPage(webInterface: WebInterface) : JsonPage("dismissNotification.ajax", webInterface) {
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest): JsonReturnObject =
request.parameters["notification"]!!
JsonPage("getLinkedElement.ajax", webInterface) {
override val needsFormPassword = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest): JsonReturnObject =
request.httpRequest.getParam("elements", "[]").asJson()
}
}
- override fun requiresLogin() = false
-
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
private fun renderLinkedElement(linkedElement: LinkedElement) =
class GetNotificationsAjaxPage(webInterface: WebInterface) : JsonPage("getNotifications.ajax", webInterface) {
override val needsFormPassword = false
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
getCurrentSone(request.toadletContext, false).let { currentSone ->
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
override val needsFormPassword = false
- override fun requiresLogin() = false
+ override val requiresLogin = false
private fun SoneOptions.toJsonOptions() = jsonObject {
put("ShowNotification/NewSones", isShowNewSoneNotifications)
}
override val needsFormPassword = false
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
createSuccessJsonObject().apply {
class GetTranslationAjaxPage(webInterface: WebInterface) : JsonPage("getTranslation.ajax", webInterface) {
override val needsFormPassword = false
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
createSuccessJsonObject()
override fun isPrefixPage() = false
open val needsFormPassword = true
- open fun requiresLogin() = true
+ open val requiresLogin = true
protected fun createSuccessJsonObject() = JsonReturnObject(true)
protected fun createErrorJsonObject(error: String) =
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)) {
+ if (requiresLogin && (sessionProvider.getCurrentSone(request.toadletContext, false) == null)) {
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString())
}
return try {
*/
class LockSoneAjaxPage(webInterface: WebInterface) : JsonPage("lockSone.ajax", webInterface) {
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
*/
open class LoggedInJsonPage(path: String, webInterface: WebInterface) : JsonPage(path, webInterface) {
- final override fun requiresLogin() = true
+ final override val requiresLogin = true
final override fun createJsonObject(request: FreenetRequest) =
createJsonObject(getCurrentSone(request.toadletContext)!!, request)
*/
class MarkAsKnownAjaxPage(webInterface: WebInterface) : JsonPage("markAsKnown.ajax", webInterface) {
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) = when (request.parameters["type"]) {
"sone" -> processIds(request, core::getSone, core::markSoneKnown)
*/
class UnbookmarkAjaxPage(webInterface: WebInterface) : JsonPage("unbookmark.ajax", webInterface) {
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["post"]
*/
class UnlockSoneAjaxPage(webInterface: WebInterface) : JsonPage("unlockSone.ajax", webInterface) {
- override fun requiresLogin() = false
+ override val requiresLogin = false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(requiresLogin))
+ assertThat(page.requiresLogin, equalTo(requiresLogin))
}
}