Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set is_authenticated first on login success #1199

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ def on_authenticate_success(self, result):
"""
Handles a successful authentication call against the API.
"""
# First set is_authenticated before calling GUI methods or emitting signals to the GUI
# since the GUI has to check authentication state in several places.
self.is_authenticated = True

logger.info("{} successfully logged in".format(self.api.username))
self.gui.hide_login()
user = storage.create_or_update_user(
Expand All @@ -488,7 +492,6 @@ def on_authenticate_success(self, result):
self.update_sources()
self.api_job_queue.start(self.api)
self.api_sync.start(self.api)
self.is_authenticated = True

def on_authenticate_failure(self, result: Exception) -> None:
# Failed to authenticate. Reset state with failure message.
Expand All @@ -505,13 +508,15 @@ def login_offline_mode(self):
"""
Allow user to view in offline mode without authentication.
"""
# First set is_authenticated before calling GUI methods or emitting signals to the GUI
# since the GUI has to check authentication state in several places.
self.is_authenticated = False
self.gui.hide_login()
# Clear clipboard contents in case of previously pasted creds (user
# may have attempted online mode login, then switched to offline)
self.gui.clear_clipboard()
self.gui.show_main_window()
storage.mark_all_pending_drafts_as_failed(self.session)
self.is_authenticated = False
self.update_sources()
self.show_last_sync()
self.show_last_sync_timer.start(TIME_BETWEEN_SHOWING_LAST_SYNC_MS)
Expand Down