X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteProfileFieldPage.kt;h=f25299f260f73c1acf04bc62f5e5253ace08f1a8;hb=d63b7445567b65ffdbd50fa8f7ffbfea1304dff9;hp=890ac74d987aef700a3be38f52571fd2a0731326;hpb=fdc047dd37e982776d55d827ca405868efe32c5a;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 890ac74..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,7 +1,7 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST -import net.pterodactylus.sone.web.pages.SoneTemplatePage import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template @@ -11,18 +11,18 @@ 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)!! - val field = currentSone.profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") - templateContext["field"] = field - if (request.isPOST) { - 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(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") + templateContext["field"] = field } }