PrettyPrinted / flask_auth_scotch

123 stars 143 forks source link

can call login page, while I am already login #3

Open morislwin opened 4 years ago

morislwin commented 4 years ago

I already login and it not show login page but I can call localhost:5000/login in new Tab and can login with different user account. How can I disabled login page while I am login. ( I mean can not call login page in new Tab)

technicallyty commented 4 years ago

Just spit-balling ideas here as I'm not an expert, but I would guess you add logic to your '/login' route to check weather the client is logged in already. if client is logged in- take them somewhere else. if they aren't show them login

kamichal commented 3 years ago

To fix it, change login method like this:

@auth.route('/login')
def login():
    if current_user.is_authenticated:
        return redirect(url_for('main.profile'))

    return render_template('login.html')

The same with sign-up:

@auth.route('/signup')
def signup():
    if current_user.is_authenticated:
        logout_user()
        return redirect(url_for('auth.signup'))

    render_template('signup.html')