projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4bf9085
)
Use a property for “requiresLogin” instead of a method
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 5 Oct 2017 19:32:20 +0000
(21:32 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 5 Oct 2017 19:32:20 +0000
(21:32 +0200)
14 files changed:
src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLinkedElementAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt
patch
|
blob
|
history
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
patch
|
blob
|
history
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt
index
f7d3cc7
..
b185d2b
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt
@@
-11,7
+11,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
class BookmarkAjaxPage(webInterface: WebInterface) : JsonPage("bookmark.ajax", webInterface) {
*/
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
override fun createJsonObject(request: FreenetRequest) =
request.parameters["post"].emptyToNull
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.kt
index
d9a354f
..
539d57b
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.kt
@@
-11,7
+11,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
class DismissNotificationAjaxPage(webInterface: WebInterface) : JsonPage("dismissNotification.ajax", webInterface) {
*/
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"]!!
override fun createJsonObject(request: FreenetRequest): JsonReturnObject =
request.parameters["notification"]!!
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLinkedElementAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLinkedElementAjaxPage.kt
index
511ed42
..
809abdc
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLinkedElementAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLinkedElementAjaxPage.kt
@@
-17,6
+17,7
@@
class GetLinkedElementAjaxPage(webInterface: WebInterface, private val elementLo
JsonPage("getLinkedElement.ajax", webInterface) {
override val needsFormPassword = false
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 createJsonObject(request: FreenetRequest): JsonReturnObject =
request.httpRequest.getParam("elements", "[]").asJson()
@@
-39,8
+40,6
@@
class GetLinkedElementAjaxPage(webInterface: WebInterface, private val elementLo
}
}
}
}
- override fun requiresLogin() = false
-
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
private fun renderLinkedElement(linkedElement: LinkedElement) =
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
private fun renderLinkedElement(linkedElement: LinkedElement) =
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
index
c3ea74c
..
19cdd24
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
@@
-17,7
+17,7
@@
import java.io.StringWriter
class GetNotificationsAjaxPage(webInterface: WebInterface) : JsonPage("getNotifications.ajax", webInterface) {
override val needsFormPassword = false
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 ->
override fun createJsonObject(request: FreenetRequest) =
getCurrentSone(request.toadletContext, false).let { currentSone ->
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt
index
925f628
..
acb8cec
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt
@@
-50,7
+50,7
@@
class GetStatusAjaxPage(webInterface: WebInterface, private val elementLoader: E
private fun String.asJson() = ObjectMapper().readTree(this).asIterable()
override val needsFormPassword = false
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)
private fun SoneOptions.toJsonOptions() = jsonObject {
put("ShowNotification/NewSones", isShowNewSoneNotifications)
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
index
759cdc0
..
6930e45
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
@@
-23,7
+23,7
@@
class GetTimesAjaxPage(webInterface: WebInterface,
}
override val needsFormPassword = false
}
override val needsFormPassword = false
- override
fun requiresLogin()
= false
+ override
val requiresLogin
= false
override fun createJsonObject(request: FreenetRequest) =
createSuccessJsonObject().apply {
override fun createJsonObject(request: FreenetRequest) =
createSuccessJsonObject().apply {
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt
index
f12a778
..
d260655
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt
@@
-10,7
+10,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
class GetTranslationAjaxPage(webInterface: WebInterface) : JsonPage("getTranslation.ajax", webInterface) {
override val needsFormPassword = false
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 createJsonObject(request: FreenetRequest) =
createSuccessJsonObject()
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
9ea1d1d
..
2da5edc
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt
@@
-25,7
+25,7
@@
abstract class JsonPage(private val path: String, protected val webInterface: We
override fun isPrefixPage() = false
open val needsFormPassword = true
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) =
protected fun createSuccessJsonObject() = JsonReturnObject(true)
protected fun createErrorJsonObject(error: String) =
@@
-41,7
+41,7
@@
abstract class JsonPage(private val path: String, protected val webInterface: We
if (needsFormPassword && request.parameters["formPassword"] != webInterface.formPassword) {
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString())
}
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 {
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString())
}
return try {
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt
index
7b3a9b2
..
8605fe6
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt
@@
-9,7
+9,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
class LockSoneAjaxPage(webInterface: WebInterface) : JsonPage("lockSone.ajax", webInterface) {
*/
class LockSoneAjaxPage(webInterface: WebInterface) : JsonPage("lockSone.ajax", webInterface) {
- override
fun requiresLogin()
= false
+ override
val requiresLogin
= false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
index
5cdee64
..
388c289
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
@@
-9,7
+9,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
open class LoggedInJsonPage(path: String, webInterface: WebInterface) : JsonPage(path, webInterface) {
*/
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)
final override fun createJsonObject(request: FreenetRequest) =
createJsonObject(getCurrentSone(request.toadletContext)!!, request)
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt
index
8053591
..
9e4e4a3
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt
@@
-12,7
+12,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
class MarkAsKnownAjaxPage(webInterface: WebInterface) : JsonPage("markAsKnown.ajax", webInterface) {
*/
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)
override fun createJsonObject(request: FreenetRequest) = when (request.parameters["type"]) {
"sone" -> processIds(request, core::getSone, core::markSoneKnown)
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt
index
11b3bbf
..
f8331fe
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt
@@
-11,7
+11,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
class UnbookmarkAjaxPage(webInterface: WebInterface) : JsonPage("unbookmark.ajax", webInterface) {
*/
class UnbookmarkAjaxPage(webInterface: WebInterface) : JsonPage("unbookmark.ajax", webInterface) {
- override
fun requiresLogin()
= false
+ override
val requiresLogin
= false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["post"]
override fun createJsonObject(request: FreenetRequest) =
request.parameters["post"]
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
index
18129f3
..
7d77c05
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
@@
-9,7
+9,7
@@
import net.pterodactylus.sone.web.page.FreenetRequest
*/
class UnlockSoneAjaxPage(webInterface: WebInterface) : JsonPage("unlockSone.ajax", webInterface) {
*/
class UnlockSoneAjaxPage(webInterface: WebInterface) : JsonPage("unlockSone.ajax", webInterface) {
- override
fun requiresLogin()
= false
+ override
val requiresLogin
= false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
index
26fde7d
..
e5621f0
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
@@
-34,7
+34,7
@@
abstract class JsonPageTest(
@Test
fun `page requires login`() {
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin
()
, equalTo(requiresLogin))
+ assertThat(page.requiresLogin, equalTo(requiresLogin))
}
}
}
}