문제

How to Skip Login Page if Active Session Exists in Flask Application.

Currently i have the Flask Application, after the successful login, am redirecting the Page to Index -

http://example.com/ --> Post Login --> http://example.com/index (Sucess)

However, when the Active Session Exists, and when i try http://example.com/ , It takes me to Login Page Again.

도움이 되었습니까?

해결책

In your login handler, simply check if the user is logged in early in the function. For example, if you're using Flask-Login:

def login():
    if current_user.is_authenticated():
        return redirect(url_for('index'))
    # process login for anon user
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top