Public pages never checked the session, so they always showed Log in. Set g.me in before_request when a session cookie is present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2616ef5060
commit
c51cf726b0
4 files changed
+37
-2
No files matched your search
+16
-1
@@ -280,6 +280,21 @@ def create_app(config=None):
|
||||
"""Add correlation ID to request context for tracing"""
|
||||
add_correlation_id()
|
||||
|
||||
# Know who is logged in on every page, not just /admin (v2.3.2), so
|
||||
# the header can say "Admin" instead of "Log in". Only requests that
|
||||
# carry a session cookie touch the database.
|
||||
from flask import g, request
|
||||
token = request.cookies.get("starpunk_session")
|
||||
if token:
|
||||
from starpunk.auth import verify_session
|
||||
try:
|
||||
info = verify_session(token)
|
||||
except Exception:
|
||||
info = None
|
||||
if info:
|
||||
g.user = info
|
||||
g.me = info["me"]
|
||||
|
||||
# Response middleware - Add webmention Link header (v1.6.0)
|
||||
@app.after_request
|
||||
def add_webmention_headers(response):
|
||||
@@ -449,5 +464,5 @@ def create_app(config=None):
|
||||
|
||||
# Package version (Semantic Versioning 2.0.0)
|
||||
# See docs/standards/versioning-strategy.md for details
|
||||
__version__ = "2.3.1"
|
||||
__version__ = "2.3.2"
|
||||
__version_info__ = (2, 1, 0)
|
||||
Reference in new issue
Block a user