X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FLoginPage.kt;h=560c607706b5d082699286574c40dce87b183a1e;hp=695816fc026289737bc04c138756eac09958bc58;hb=d5bf199171aa509d295985453db0cc130c3665a8;hpb=de7568a82eb4150bf6d2b0553841b7b69f84c968 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt index 695816f..560c607 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt @@ -2,6 +2,7 @@ package net.pterodactylus.sone.web.pages import freenet.clients.http.ToadletContext import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.utils.emptyToNull import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.web.pages.SoneTemplatePage import net.pterodactylus.sone.web.WebInterface @@ -20,7 +21,7 @@ class LoginPage(template: Template, webInterface: WebInterface): val soneId = request.httpRequest.getPartAsStringFailsafe("sone-id", 43) webInterface.core.getLocalSone(soneId)?.let { sone -> setCurrentSone(request.toadletContext, sone) - val target = if (request.httpRequest.isParameterSet("target")) request.httpRequest.getPartAsStringFailsafe("target", 256) else "index.html" + val target = request.httpRequest.getParam("target").emptyToNull ?: "index.html" throw RedirectException(target) } } @@ -33,7 +34,7 @@ class LoginPage(template: Template, webInterface: WebInterface): override fun isEnabled(toadletContext: ToadletContext) = when { webInterface.core.preferences.isRequireFullAccess && !toadletContext.isAllowedFullAccess -> false - else -> getCurrentSoneWithoutCreatingSession(toadletContext) == null + else -> getCurrentSone(toadletContext, false) == null } }