Skip to content

Commit

Permalink
fix: remove user credential from keyring (#2627)
Browse files Browse the repository at this point in the history
  • Loading branch information
divyaajainn authored Feb 21, 2025
1 parent aed300b commit f8f314d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from PyQt5.QtWidgets import QDialog, QFileDialog, QMessageBox
from PyQt5.QtGui import QPixmap

from mslib.utils.auth import get_password_from_keyring, save_password_to_keyring
from mslib.utils.auth import get_password_from_keyring, save_password_to_keyring, del_password_from_keyring
from mslib.utils.verify_user_token import verify_user_token as _verify_user_token
from mslib.utils.verify_waypoint_data import verify_waypoint_data
from mslib.utils.qt import get_open_filename, get_save_filename, dropEvent, dragEnterEvent, show_popup
Expand Down Expand Up @@ -936,6 +936,9 @@ def delete_own_account(self, _=None):
if reply == QMessageBox.No:
return
try:
auth_name = config_loader(dataset="MSCOLAB_auth_user_name")
del_password_from_keyring(self.mscolab_server_url, self.email)
del_password_from_keyring(f"MSCOLAB_AUTH_{self.mscolab_server_url}", auth_name)
response = self.conn.request_post("delete_own_account")
except requests.exceptions.RequestException as ex:
raise MSColabConnectionError(f"Some error occurred ({ex})! Please reconnect.")
Expand Down
10 changes: 10 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,20 @@ def test_user_delete(self, mockmessage, qtbot):
self._create_user(qtbot, "something", "something@something.org", "something")
u_id = self.window.mscolab.user['id']
self.window.mscolab.open_profile_window()
# Uses 'TestKeyring' from conftest.py for verification.
assert self.url + "something@something.org" in mslib.utils.auth.keyring.get_keyring().passwords
assert "MSCOLAB_AUTH_" + self.url, "something@something.org" in mslib.utils.auth.keyring.get_keyring().passwords
QtTest.QTest.mouseClick(self.window.mscolab.profile_dialog.deleteAccountBtn, QtCore.Qt.LeftButton)
assert self.window.listOperationsMSC.model().rowCount() == 0
assert self.window.usernameLabel.isVisible() is False
assert self.window.connectBtn.isVisible() is True
assert (
self.url + "something@something.org"
not in mslib.utils.auth.keyring.get_keyring().passwords
)
assert "MSCOLAB_AUTH_" + self.url, "something@something.org" not in (
mslib.utils.auth.keyring.get_keyring().passwords
)
with self.app.app_context():
assert User.query.filter_by(emailid='something').count() == 0
assert Permission.query.filter_by(u_id=u_id).count() == 0
Expand Down

0 comments on commit f8f314d

Please sign in to comment.