Logo
Explore Help
Sign In
darkhelm/notifications-admin
1
0
Fork 0
You've already forked notifications-admin
mirror of https://github.com/GSA/notifications-admin.git synced 2026-07-18 13:39:57 -04:00
Code Issues Packages Projects Releases Wiki Activity
Files
4d0da6594de60fcf37dc7796279462e32072d7a1
notifications-admin/app/main/views/sign_out.py

13 lines
318 B
Python
Raw Normal View History

- Add unit test for when case when the cookie doesn't match the db. - Move code into User.signout method to further encapsulate the code.
2020-02-03 15:08:55 +00:00
from flask import redirect, url_for
from flask_login import current_user
Logout functionality and test added.
2016-01-06 16:40:38 +00:00
from app.main import main
@main.route('/sign-out', methods=(['GET']))
def sign_out():
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.
2020-02-04 12:16:58 +00:00
# An AnonymousUser does not have an id
if current_user.is_authenticated:
current_user.sign_out()
Redirect to homepage after signout
2016-06-21 09:40:04 +01:00
return redirect(url_for('main.index'))
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.0 Page: 1230ms Template: 69ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API