-
Notifications
You must be signed in to change notification settings - Fork 645
Fix owner removal for duplicate logins #9930
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
Conversation
5d8277a
to
431026d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9930 +/- ##
==========================================
+ Coverage 89.07% 89.08% +0.01%
==========================================
Files 290 290
Lines 30060 30145 +85
==========================================
+ Hits 26776 26855 +79
- Misses 3284 3290 +6 ☔ View full report in Codecov by Sentry. |
Wait, what about this case:
I think what you're saying is this PR would delete the record for Person A when Person B logs in??? So when Person A logs in again, their account/ownership stuff would be gone? |
OH WAIT I think I'm confused. I read this line:
and thought the records in the |
yep, exactly :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on first glance :)
Ah, and should we add some tests for the team-related parts? |
I've added #9943 just now, but it looks like there is no fix needed for that issue since it already works as intended. |
If I understand correctly, in this case, Person B is not the owner of the crate, and they also do not have permission to change the owner. So, there should not be an issue here. |
When users or teams on GitHub are deleted and recreated they might exist multiple times within our own database with the same `login`. When owners are deleted, only the newest matching `login` is considered for deletion though, which makes it impossible to delete older users/teams. This commit fixes the problem by deleting **all** owners with a matching `login` instead. Unfortunately, `diesel` does not support `UPDATE` queries with `JOINs`, so this has to be a "raw" SQL query with bindings instead…
This fn isn't used anymore…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regression test confirms that the issue has been fixed as expected. The SQL part leverages bind
, which should prevent any injection attacks.
Nice work, thanks 👍
When users or teams on GitHub are deleted and recreated they might exist multiple times within our own database with the same
login
. When owners are deleted, only the newest matchinglogin
is considered for deletion though, which makes it impossible to delete older users/teams.This commit fixes the problem by deleting all owners with a matching
login
instead.Unfortunately,
diesel
does not supportUPDATE
queries withJOINs
, so this has to be a "raw" SQL query with bindings instead…Fixes #2736,
and AFAICT also fixes #1205Related: