Skip to content

Commit

Permalink
fix: check user in helper (#83407)
Browse files Browse the repository at this point in the history
  • Loading branch information
oioki authored and andrewshie-sentry committed Jan 22, 2025
1 parent 814dfa5 commit 47a791b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sentry/auth/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def handle_unknown_identity(
elif not self._has_usable_password():
is_new_account = True

if op == "confirm" and self.user.is_authenticated or is_account_verified:
if op == "confirm" and (self.request.user.id == self.user.id) or is_account_verified:
auth_identity = self.handle_attach_identity()
elif op == "newuser":
auth_identity = self.handle_new_user()
Expand Down
11 changes: 11 additions & 0 deletions tests/sentry/web/frontend/test_auth_saml2.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,14 @@ def test_logout_request(self):

updated = type(self.user).objects.get(pk=self.user.id)
assert updated.session_nonce != self.user.session_nonce

def test_verify_email(self, follow=False, **kwargs):
assert AuthIdentity.objects.filter(user_id=self.user.id).count() == 0

response = self.accept_auth()
assert response.status_code == 200

response = self.client.post(self.acs_path, {"op": "confirm"})

# expect no linking before verification
assert AuthIdentity.objects.filter(user_id=self.user.id).count() == 0

0 comments on commit 47a791b

Please sign in to comment.