Requested by Quokka to make logins redirect back to the page

This commit is contained in:
BlenderDumbass 2024-12-02 16:43:03 +02:00
parent 6b5d67f429
commit 1f6dd90118
2 changed files with 16 additions and 5 deletions

View file

@ -556,7 +556,7 @@ def ArticlePage(server, url):
if referrers:
for referrer in referrers:
# Filtering out probably bad links.
if "https://" in referrer and ".onion" not in referrer:
if ( "https://" in referrer and ".onion" not in referrer ) or rank(user.get("username", "")) == 0:
html = html + Safe(referrer) + " : 👁 "+str(referrers[referrer]) + "<br>\n"
@ -893,6 +893,7 @@ def LoginPage(server):
f = Set.Folder()
wrongname = server.parsed.get("wrong", [""])[0]
redirect = server.parsed.get("redirect", [""])[0]
# Generating <head>
html = head(title = "Login",
@ -921,6 +922,12 @@ def LoginPage(server):
<img style="vertical-align: middle" src="/icon/lock">
<input class="button" style="width:90%" maxlength="500" id="password" type="password" required="" name="password" placeholder="Password..."></input><br>
"""
if redirect:
html = html + '<input type="hidden" name="redirect" value="'+Safe(redirect)+'">'
html = html + """
<button class="button" type="submit">
<img style="vertical-align: middle" src="/icon/unlock">
Login
@ -1717,7 +1724,7 @@ def LoginButton(server):
html = '<div class="login_fixed">'
if not user:
html = html + '<a class="button" href="/login">'
html = html + '<a class="button" href="/login?redirect='+urllib.parse.quote_plus(server.path)+'">'
html = html + '<img alt="[icon user]" style="vertical-align: middle" src="/icon/unlock"> Login'
html = html + '</a>'
@ -1800,6 +1807,8 @@ def Login(server):
username = server.parsed.get("user_name", [""])[0]
password = server.parsed.get("password" , [""])[0]
hashed = hashlib.sha512(password.encode("utf-8")).hexdigest()
redirect = server.parsed.get("redirect" , [""])[0]
Accounts = accounts()
@ -1852,9 +1861,11 @@ def Login(server):
json.dump(article, save, indent=4)
if not redirect:
Redirect(server, "/settings")
else:
Redirect(server, redirect)
Redirect(server, "/settings")
def Register(server):
# If by mistake we are logged in

View file

@ -399,7 +399,7 @@ def search_convert(s):
r = r + i
return r
def convert(filename, isfile=True, fullpath=True):
def convert(filename, isfile=True, fullpath=False):
if fullpath: