X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteProfileFieldPage.kt;h=f25299f260f73c1acf04bc62f5e5253ace08f1a8;hb=74cbe983cd38da24847e6247ac595cb70d8e115b;hp=63cf17fb59e2d28c99bfe0d66c2918a11724ce29;hpb=5ba707d40f9d2a20094aaabc21647aeec1feed46;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt index 63cf17f..f25299f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt @@ -1,5 +1,6 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest @@ -10,18 +11,17 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user confirm the deletion of a profile field. */ class DeleteProfileFieldPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface, true) { + LoggedInPage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val currentSone = getCurrentSone(request.toadletContext)!! - if (request.isPOST) { - val field = currentSone.profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") - if (request.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val field = currentSone.profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") + if (freenetRequest.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") { currentSone.profile = currentSone.profile.apply { removeField(field) } } throw RedirectException("editProfile.html#profile-fields") } - val field = currentSone.profile.getFieldById(request.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") + val field = currentSone.profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") templateContext["field"] = field }