Clean up some imports
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DeleteProfileFieldPage.kt
index 890ac74..63cf17f 100644 (file)
@@ -1,7 +1,6 @@
 package net.pterodactylus.sone.web.pages
 
 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
@@ -15,14 +14,15 @@ class DeleteProfileFieldPage(template: Template, webInterface: 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) {
+                       val field = currentSone.profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
                        if (request.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")
+               templateContext["field"] = field
        }
 
 }