X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditProfilePage.kt;h=93393ba957a0371a62eb1180c2a1314ecbee750a;hp=f4baadc0415317be526dbfdf142ee836152258e7;hb=HEAD;hpb=c389ee8f5e6eacae70438c3f364e8674c09d1959 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt index f4baadc..93393ba 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt @@ -17,7 +17,7 @@ import javax.inject.* @TemplatePath("/templates/editProfile.html") @ToadletPath("editProfile.html") class EditProfilePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : - LoggedInPage("editProfile.html", "Page.EditProfile.Title", webInterface, loaders, templateRenderer) { + LoggedInPage("Page.EditProfile.Title", webInterface, loaders, templateRenderer) { override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { currentSone.profile.let { profile -> @@ -43,31 +43,31 @@ class EditProfilePage @Inject constructor(webInterface: WebInterface, loaders: L } currentSone.profile = profile soneRequest.core.touchConfiguration() - throw RedirectException("editProfile.html") + redirectTo("editProfile.html") } else if (soneRequest.httpRequest.getPartAsStringFailsafe("add-field", 4) == "true") { val fieldName = soneRequest.httpRequest.getPartAsStringFailsafe("field-name", 100) try { profile.addField(fieldName) currentSone.profile = profile soneRequest.core.touchConfiguration() - throw RedirectException("editProfile.html#profile-fields") + redirectTo("editProfile.html#profile-fields") } catch (e: DuplicateField) { templateContext["fieldName"] = fieldName templateContext["duplicateFieldName"] = true } } else profile.fields.forEach { field -> if (soneRequest.httpRequest.getPartAsStringFailsafe("delete-field-${field.id}", 4) == "true") { - throw RedirectException("deleteProfileField.html?field=${field.id}") + redirectTo("deleteProfileField.html?field=${field.id}") } else if (soneRequest.httpRequest.getPartAsStringFailsafe("edit-field-${field.id}", 4) == "true") { - throw RedirectException("editProfileField.html?field=${field.id}") + redirectTo("editProfileField.html?field=${field.id}") } else if (soneRequest.httpRequest.getPartAsStringFailsafe("move-down-field-${field.id}", 4) == "true") { profile.moveFieldDown(field) currentSone.profile = profile - throw RedirectException("editProfile.html#profile-fields") + redirectTo("editProfile.html#profile-fields") } else if (soneRequest.httpRequest.getPartAsStringFailsafe("move-up-field-${field.id}", 4) == "true") { profile.moveFieldUp(field) currentSone.profile = profile - throw RedirectException("editProfile.html#profile-fields") + redirectTo("editProfile.html#profile-fields") } } }