- Notifications
You must be signed in to change notification settings - Fork923
fix: do not query user_link for deleted accounts#12112
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
15 commits Select commitHold shift + click to select a range
e2b787c
chore: add database test fixture to insert non-unique linked_ids
Emyrk43356ed
mend
Emyrk2791347
mend
Emyrk549fee9
rename test fixute
Emyrk7b082ef
add extra case
Emyrk90e7164
accidental file change
Emyrkfdf04ed
move migration closer to source
Emyrkb1e066e
chore: add database test fixture to insert non-unique linked_ids
Emyrkcce73c6
mend
Emyrkc0dc8a6
mend
Emyrk53a37ee
rename test fixute
Emyrkc751ccf
accidental file change
Emyrk5ee1017
chore: creaet unit test to exercise failed email change bug
Emyrkf14d37f
fix: do not use user_link for deleted accounts
Emyrkb0c3cbb
Add links to existing issues
EmyrkFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletionscoderd/database/dbmem/dbmem.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletionscoderd/database/migrations/testdata/fixtures/000048_userdelete.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- This is a deleted user that shares the same username and linked_id as the existing user below. | ||
-- Any future migrations need to handle this case. | ||
INSERT INTO public.users(id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, deleted) | ||
VALUES ('a0061a8e-7db7-4585-838c-3116a003dd21', 'githubuser@coder.com', 'githubuser', '\x', '2022-11-02 13:05:21.445455+02', '2022-11-02 13:05:21.445455+02', 'active', '{}', true) ON CONFLICT DO NOTHING; | ||
INSERT INTO public.organization_members VALUES ('a0061a8e-7db7-4585-838c-3116a003dd21', 'bb640d07-ca8a-4869-b6bc-ae61ebb2fda1', '2022-11-02 13:05:21.447595+02', '2022-11-02 13:05:21.447595+02', '{}') ON CONFLICT DO NOTHING; | ||
INSERT INTO public.user_links(user_id, login_type, linked_id, oauth_access_token) | ||
VALUES('a0061a8e-7db7-4585-838c-3116a003dd21', 'github', '100', ''); | ||
INSERT INTO public.users(id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, deleted) | ||
VALUES ('fc1511ef-4fcf-4a3b-98a1-8df64160e35a', 'githubuser@coder.com', 'githubuser', '\x', '2022-11-02 13:05:21.445455+02', '2022-11-02 13:05:21.445455+02', 'active', '{}', false) ON CONFLICT DO NOTHING; | ||
INSERT INTO public.organization_members VALUES ('fc1511ef-4fcf-4a3b-98a1-8df64160e35a', 'bb640d07-ca8a-4869-b6bc-ae61ebb2fda1', '2022-11-02 13:05:21.447595+02', '2022-11-02 13:05:21.447595+02', '{}') ON CONFLICT DO NOTHING; | ||
INSERT INTO public.user_links(user_id, login_type, linked_id, oauth_access_token) | ||
VALUES('fc1511ef-4fcf-4a3b-98a1-8df64160e35a', 'github', '100', ''); | ||
-- Additionally, there is no unique constraint on user_id. So also add another user_link for the same user. | ||
-- This has happened on a production database. | ||
INSERT INTO public.user_links(user_id, login_type, linked_id, oauth_access_token) | ||
VALUES('fc1511ef-4fcf-4a3b-98a1-8df64160e35a', 'oidc', 'foo', ''); |
6 changes: 5 additions & 1 deletioncoderd/database/queries.sql.go
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
8 changes: 6 additions & 2 deletionscoderd/database/queries/user_links.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
29 changes: 24 additions & 5 deletionscoderd/userauth_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.