summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-06-15 20:25:49 +0000
committerubq323 <ubq323>2021-06-15 20:25:49 +0000
commitb558787d8146894709c42340f85c5bea4418e081 (patch)
treefa919101fd36d98351a824432c582e8a06264347
parenta4461d18a3a4b1a8317747242465f1c7f7caa08f (diff)
fix crash when logging in or out on search results page
-rw-r--r--apioforum/__init__.py10
-rw-r--r--apioforum/templates/base.html6
2 files changed, 12 insertions, 4 deletions
diff --git a/apioforum/__init__.py b/apioforum/__init__.py
index 7baa7c1..c4348a3 100644
--- a/apioforum/__init__.py
+++ b/apioforum/__init__.py
@@ -1,7 +1,7 @@
# boilerplate boilerplate boilerplate
# yay
-from flask import Flask
+from flask import Flask, request
from .db import get_db
import os
@@ -32,6 +32,14 @@ def create_app():
from .fuzzy import fuzzy
app.jinja_env.filters['fuzzy']=fuzzy
+ @app.context_processor
+ def path_for_next():
+ p = request.path
+ if len(request.query_string) > 0:
+ p += "?" + request.query_string.decode("utf-8")
+ return dict(path_for_next=p)
+
+
app.add_url_rule("/",endpoint="index")
return app
diff --git a/apioforum/templates/base.html b/apioforum/templates/base.html
index ba96c91..87b142f 100644
--- a/apioforum/templates/base.html
+++ b/apioforum/templates/base.html
@@ -21,18 +21,18 @@
{% if g.user %}
<p>{{ g.user }}</p>
<p>
- <a href="{{ url_for('auth.logout',next=request.path) }}">
+ <a href="{{ url_for('auth.logout',next=path_for_next) }}">
logout
</a>
</p>
{% else %}
<p>
- <a href="{{ url_for('auth.login',next=request.path) }}">
+ <a href="{{ url_for('auth.login',next=path_for_next) }}">
login
</a>
</p>
<p>
- <a href="{{ url_for('auth.register',next=request.path) }}">
+ <a href="{{ url_for('auth.register',next=path_for_next) }}">
register
</a>
</p>