X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUploadImagePage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUploadImagePage.kt;h=392b272a2c3f72ca58c4b9bd357e96016dcdbbf2;hp=de61835aef6ccc704911abe58149dc51ccf3c7ba;hb=aaf780d3c2a6f5ce47295786f3963c8b93f6a145;hpb=16cdb3cc357d30441ddcb13c8841f9928fdb0adb diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt index de61835..392b272 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt @@ -23,11 +23,11 @@ class UploadImagePage @Inject constructor(webInterface: WebInterface, loaders: L override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { if (soneRequest.isPOST) { - val parentAlbum = soneRequest.parameters["parent"]!!.let(soneRequest.core::getAlbum) ?: throw RedirectException("noPermission.html") + val parentAlbum = soneRequest.parameters["parent"]!!.let(soneRequest.core::getAlbum) ?: redirectTo("noPermission.html") if (parentAlbum.sone != currentSone) { - throw RedirectException("noPermission.html") + redirectTo("noPermission.html") } - val title = soneRequest.parameters["title", 200].emptyToNull ?: throw RedirectException("emptyImageTitle.html") + val title = soneRequest.parameters["title", 200].emptyToNull ?: redirectTo("emptyImageTitle.html") val uploadedFile = soneRequest.httpRequest.getUploadedFile("image") val bytes = uploadedFile.data.use { it.toByteArray() } @@ -44,7 +44,7 @@ class UploadImagePage @Inject constructor(webInterface: WebInterface, loaders: L setTitle(title) setDescription(TextFilter.filter(soneRequest.headers["Host"], soneRequest.parameters["description", 4000])) }.update() - throw RedirectException("imageBrowser.html?album=${parentAlbum.id}") + redirectTo("imageBrowser.html?album=${parentAlbum.id}") } }