Skip to content

Commit

Permalink
set is_authenticated first on login
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Dec 10, 2020
1 parent 6e1e9e0 commit 3227fb5
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 3227fb5

Please sign in to comment.