X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FEditProfileFieldAjaxPage.kt;h=e48c92dca646a015439d4cc56ac5fa6c97432ef2;hp=72ee0059f1b2527f820efc1d6307f0a29fd43881;hb=9e697ac643d11a2b7644a948732674eea195718a;hpb=e4969210bb1c68af8dc434478440516a81d91c6d diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt index 72ee005..e48c92d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt @@ -1,5 +1,6 @@ package net.pterodactylus.sone.web.ajax +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.ifFalse import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface @@ -8,10 +9,10 @@ import net.pterodactylus.sone.web.page.FreenetRequest /** * AJAX page that lets the user rename a profile field. */ -class EditProfileFieldAjaxPage(webInterface: WebInterface) : JsonPage("editProfileField.ajax", webInterface) { +class EditProfileFieldAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("editProfileField.ajax", webInterface) { - override fun createJsonObject(request: FreenetRequest) = - getCurrentSone(request.toadletContext).profile.let { profile -> + override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = + currentSone.profile.let { profile -> request.parameters["field"]!! .let(profile::getFieldById) ?.let { field -> @@ -20,7 +21,7 @@ class EditProfileFieldAjaxPage(webInterface: WebInterface) : JsonPage("editProfi try { field.name = newName createSuccessJsonObject().also { - getCurrentSone(request.toadletContext).profile = profile + currentSone.profile = profile } } catch (_: IllegalArgumentException) { createErrorJsonObject("duplicate-field-name")