X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditProfileFieldPage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditProfileFieldPage.kt;h=be681e3a14de93c445876818b6ae09894d5ae422;hp=8109e3a5d72838d22e194337ff528a1dcedcf4e2;hb=05fb821e72072bde52f383bdc5a988da67f66d0c;hpb=f0c1becb30b360bf414ca9cbdd5df61490a9393c diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt index 8109e3a..be681e3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt @@ -15,11 +15,11 @@ class EditProfileFieldPage(template: Template, webInterface: WebInterface): override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { sessionProvider.getCurrentSone(request.toadletContext)!!.let { currentSone -> currentSone.profile.let { profile -> - val field = profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") if (request.isPOST) { if (request.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") { throw RedirectException("editProfile.html#profile-fields") } + val field = profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") request.httpRequest.getPartAsStringFailsafe("name", 256).let { name -> try { if (name != field.name) { @@ -29,10 +29,11 @@ class EditProfileFieldPage(template: Template, webInterface: WebInterface): throw RedirectException("editProfile.html#profile-fields") } catch (e: IllegalArgumentException) { templateContext["duplicateFieldName"] = true + return } } } - templateContext["field"] = field + templateContext["field"] = profile.getFieldById(request.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") } } }