Check if user is authenticated before signing out, this will prevent a 500 if the user is an AnonymousUser.

I ended up creating a new test user and logged_in_client, which isn't really great. But I tried adding a current_session_id to the active user in the test, but that broke all other tests.
I tried setting current_session_id in all the users being tested but that didn't work either. I'd like to come back to fixing the tests and reducing the number of conftest methods in another PR. For now this fixes the bug.
This commit is contained in:
Rebecca Law
2020-02-04 12:16:58 +00:00
parent 18523587a6
commit 8a19d9496a
3 changed files with 59 additions and 3 deletions

View File

@@ -6,5 +6,7 @@ from app.main import main
@main.route('/sign-out', methods=(['GET']))
def sign_out():
current_user.sign_out()
# An AnonymousUser does not have an id
if current_user.is_authenticated:
current_user.sign_out()
return redirect(url_for('main.index'))