Skip to content

Commit

Permalink
Prevent deleted users from logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
seanh committed May 23, 2024
1 parent 508e446 commit 56d468b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion h/services/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def fetch_for_login(self, username_or_email):

user = self.session.query(User).filter(*filters).one_or_none()

if user is None:
if user is None or user.deleted:
return None

if not user.is_activated:
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/h/services/user_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ def test_fetch_for_login_by_email_not_activated(self, svc):
with pytest.raises(UserNotActivated):
svc.fetch_for_login("mirthe@deboer.com")

def test_fetch_for_login_by_username_deleted(self, svc, factories):
user = factories.User(deleted=True)

assert svc.fetch_for_login(user.username) is None

def test_fetch_for_login_by_email_deleted(self, svc, factories):
user = factories.User(deleted=True)

assert svc.fetch_for_login(user.email) is None

def test_update_preferences_tutorial_enable(self, svc, factories):
user = factories.User.build(sidebar_tutorial_dismissed=True)

Expand Down

0 comments on commit 56d468b

Please sign in to comment.