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
Files changed (1) hide show
  1. api.py +5 -2
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':