Spaces:
Running
Running
David Ko
commited on
Commit
ยท
337664f
1
Parent(s):
6de8fab
Fix redirect loop: show login page if session is authenticated but not fresh; only redirect to index when fresh
Browse files
api.py
CHANGED
@@ -1187,9 +1187,12 @@ LOGIN_TEMPLATE = '''
|
|
1187 |
@app.route('/login', methods=['GET', 'POST'])
|
1188 |
def login():
|
1189 |
# ์ด๋ฏธ ๋ก๊ทธ์ธ๋ ์ฌ์ฉ์๋ ๋ฉ์ธ ํ์ด์ง๋ก ๋ฆฌ๋๋ ์
|
1190 |
-
if current_user.is_authenticated:
|
1191 |
-
print(f"User already authenticated as: {current_user.username}, redirecting to index")
|
1192 |
return redirect('/index.html')
|
|
|
|
|
|
|
1193 |
|
1194 |
error = None
|
1195 |
if request.method == 'POST':
|
|
|
1187 |
@app.route('/login', methods=['GET', 'POST'])
|
1188 |
def login():
|
1189 |
# ์ด๋ฏธ ๋ก๊ทธ์ธ๋ ์ฌ์ฉ์๋ ๋ฉ์ธ ํ์ด์ง๋ก ๋ฆฌ๋๋ ์
|
1190 |
+
if current_user.is_authenticated and login_fresh():
|
1191 |
+
print(f"User already authenticated and fresh as: {current_user.username}, redirecting to index")
|
1192 |
return redirect('/index.html')
|
1193 |
+
elif current_user.is_authenticated and not login_fresh():
|
1194 |
+
# Remember-cookie ์ํ ๋ฑ ๋น-ํ๋ ์ ์ธ์
์ด๋ฉด ๋ก๊ทธ์ธ ํ์ด์ง๋ฅผ ๋ณด์ฌ์ ์ฌ์ธ์ฆ ์ ๋
|
1195 |
+
print("User authenticated but session not fresh; showing login page for reauthentication")
|
1196 |
|
1197 |
error = None
|
1198 |
if request.method == 'POST':
|