X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteAlbumPage.kt;h=eff79b95fddf7b17eac177ecc35ca60a8b613ff1;hb=74cbe983cd38da24847e6247ac595cb70d8e115b;hp=8009c72e2bbba1885996ca530273611c817e743a;hpb=05fb821e72072bde52f383bdc5a988da67f66d0c;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 8009c72..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,7 +1,7 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST -import net.pterodactylus.sone.web.pages.SoneTemplatePage import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template @@ -11,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") }