Pergunta

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.

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top