Ensure that the session is logged out server side, not just client side.

Anytime a user clicks "sign out" we should be signing them out server side as well. This can be accomplished by setting the Users.current_session_id = null.
I found that the method User.logged_in_elsewhere doesn't need to check if the current_session_id is None. The current_session_ids in the cookie and db (redis or postgres) then the user should be forced to log in again.
This commit is contained in:
Rebecca Law
2020-01-31 15:50:55 +00:00
parent a49b492ade
commit 937c9f2adc
5 changed files with 12 additions and 8 deletions

View File

@@ -1,11 +1,12 @@
from flask import redirect, session, url_for
from flask_login import logout_user
from flask_login import current_user, logout_user
from app.main import main
@main.route('/sign-out', methods=(['GET']))
def sign_out():
current_user.sign_out()
session.clear()
logout_user()
return redirect(url_for('main.index'))