X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteAlbumPage.kt;h=eff79b95fddf7b17eac177ecc35ca60a8b613ff1;hb=d63b7445567b65ffdbd50fa8f7ffbfea1304dff9;hp=66f989a29dca47fb62db54f1367b4063973cdb06;hpb=5ba707d40f9d2a20094aaabc21647aeec1feed46;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt index 66f989a..eff79b9 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt @@ -1,5 +1,6 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest @@ -10,21 +11,21 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user delete an {@link Album}. */ class DeleteAlbumPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface, true) { + LoggedInPage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val album = webInterface.core.getAlbum(request.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") if (!album.sone.isLocal) { throw RedirectException("noPermission.html") } - if (request.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { throw RedirectException("imageBrowser.html?album=${album.id}") } webInterface.core.deleteAlbum(album) throw RedirectException(if (album.parent.isRoot) "imageBrowser.html?sone=${album.sone.id}" else "imageBrowser.html?album=${album.parent.id}") } - val album = webInterface.core.getAlbum(request.httpRequest.getParam("album")) + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getParam("album")) templateContext["album"] = album ?: throw RedirectException("invalid.html") }