Skip to content

fix: check user in helper #83407

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

Merged
merged 1 commit into from
Jan 14, 2025
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
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
Loading