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

improved handling on a server restart, token invalidation #1906

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
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 mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ def get_recent_op_id(self):
return op_id
else:
show_popup(self.ui, "Error", "Session expired, new login required")
self.signal_logout_mscolab()
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
Expand Down Expand Up @@ -1510,8 +1511,12 @@ def show_categories_to_ui(self):
data = {
"token": self.token
}
r = requests.get(f'{self.mscolab_server_url}/operations', data=data, timeout=(2, 10))
if r.text != "False":
r = None
try:
r = requests.get(f'{self.mscolab_server_url}/operations', data=data, timeout=(2, 10))
except requests.exceptions.MissingSchema:
show_popup(self.ui, "Error", "Session expired, new login required")
if r is not None and r.text != "False":
_json = json.loads(r.text)
operations = _json["operations"]
self.ui.filterCategoryCb.clear()
Expand Down
2 changes: 1 addition & 1 deletion mslib/msui/mscolab_admin_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def set_label_text(self):
if r.text != "False":
_json = json.loads(r.text)
creator_name = _json["username"]
self.operationNameLabel.setText(f"Operation: {self.operation_name} by User: {creator_name}")
self.operationNameLabel.setText(f"Operation: {self.operation_name} by User: {creator_name}")
self.usernameLabel.setText(f"Logged In: {self.user['username']}")

def load_import_operations(self):
Expand Down
10 changes: 7 additions & 3 deletions mslib/msui/msui.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from mslib.utils import setup_logging
from mslib.plugins.io.csv import load_from_csv, save_to_csv
from mslib.msui.icons import icons, python_powered
from mslib.utils.qt import get_open_filenames, get_save_filename, Worker, Updater
from mslib.utils.qt import get_open_filenames, get_save_filename, show_popup, Worker, Updater
from mslib.utils.config import read_config_file, config_loader
from mslib.utils.auth import get_auth_from_url_and_name
from PyQt5 import QtGui, QtCore, QtWidgets, QtTest
Expand Down Expand Up @@ -881,8 +881,12 @@ def create_view_handler(self, _type):
if self.local_active:
self.create_view(_type, self.active_flight_track)
else:
self.mscolab.waypoints_model.name = self.mscolab.active_operation_name
self.create_view(_type, self.mscolab.waypoints_model)
try:
self.mscolab.waypoints_model.name = self.mscolab.active_operation_name
self.create_view(_type, self.mscolab.waypoints_model)
except AttributeError:
# can happen, when the servers secret was changed
show_popup(self.mscolab.ui, "Error", "Session expired, new login required")

def create_view(self, _type, model):
"""Method called when the user selects a new view to be opened. Creates
Expand Down