Вопрос

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