after upgrade from Flask-Login-0.4.1 to flask-login-0.5.0 my old code can't login again because of "redirected you too many times" error .
I use flask blueprint model for my app and the login part handled with flask-login.
I asked flask-login(in github : https://github.com/maxcountryman/flask-login/issues/564) .
flask : 1.1.2
Werkzeug : 1.0.1
This is part of my code related to flask-login :
@auth.route('/login', methods=('GET', 'POST'))
def login():
if current_user.is_authenticated:
return redirect(url_for("indexb.index", title=branding_title))
if request.method == "POST":
user = User.query.filter_by(username=request.form["username"]).first()
if user and user.check_password(request.form["password"]):
login_user(user)
return redirect(url_for("indexb.index", title=branding_title))
else:
flash("invalid user Cred !")
return redirect(url_for("auth.login", title=branding_title))
return render_template('auth/login.html')
@auth.before_app_request
def load_logged_in_user():
user_id = session.get('user_id')
if user_id is None:
g.user = None
else:
g.user = current_user
@auth.route('/logout')
def logout():
session.clear()
return redirect(url_for('indexb.index'))
def login_required(view):
@functools.wraps(view)
def wrapped_view(**kwargs):
if g.user is None:
return redirect(url_for('auth.login'))
return view(**kwargs)
return wrapped_view
question from:
https://stackoverflow.com/questions/65933275/upgrade-to-flask-login-0-5-0-from-flask-login-0-4-1-redirected-you-too-many-time 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…