X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUntrustPage.kt;h=74a34b8ccef242984875e86de30713fe3aeb3219;hb=1557106d0e373f7efc15faed65f69eb567613a45;hp=a46b272bcf4370033326ecf3c5dd65cdfa4fb0c0;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt index a46b272..74a34b8 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt @@ -1,27 +1,26 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.utils.also +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that lets the user untrust another Sone. This will remove all trust * assignments for an identity. */ -class UntrustPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("untrust.html", template, "Page.Untrust.Title", webInterface, true) { +class UntrustPage @Inject constructor(template: Template, webInterface: WebInterface) : + LoggedInPage("untrust.html", template, "Page.Untrust.Title", webInterface) { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { - getCurrentSone(freenetRequest.toadletContext)!!.also { currentSone -> - freenetRequest.parameters["sone", 44] - .let(webInterface.core::getSone) - .also { webInterface.core.untrustSone(currentSone, it) } - } + freenetRequest.parameters["sone", 44]!! + .let(webInterface.core::getSone) + ?.also { webInterface.core.untrustSone(currentSone, it) } throw RedirectException(freenetRequest.parameters["returnPage", 256]) } }