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