Skip to content

feat(auth): Add ability to link a federated id with the UpdateUser() method. #344

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 22 commits into from
Mar 23, 2021

Conversation

rsgowman
Copy link
Member

@rsgowman rsgowman commented Mar 5, 2020

No description provided.

@rsgowman
Copy link
Member Author

rsgowman commented Mar 5, 2020

Note the diffbase. I'll merge+retarget to dev once the bulk_get stuff lands.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. Just some comments on style.

auth/user_mgt.go Outdated
if _, ok := req["email"]; ok {
// We could relax this to only return an error if the email addrs don't
// match. But for now, we'll be extra picky.
return nil, fmt.Errorf(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use errors.New() when the error message doesn't contain any formatting directives.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

auth/user_mgt.go Outdated
// We could relax this to only return an error if the email addrs don't
// match. But for now, we'll be extra picky.
return nil, fmt.Errorf(
"Both UserToUpdate.Email and UserToUpdate.ProviderToLink.ProviderID='email' " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error messages do not exactly follow the Go convention: https://github.com/golang/go/wiki/Errors (i.e. start with a lowercase letter etc). But we also don't strictly adhere to those conventions. So I'd leave it to your judgement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed it. (Lower case, remove ending punctuation.) Hopefully throughout.

// exists.
// TODO(rsgowman): This function was ported from node.js port; a number of tests
// there use this, but haven't been ported to go yet. Do so.
func deletePhoneNumberUser(t *testing.T, phoneNumber string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really ought to stop passing t to helper functions. Instead return an error from this function, and handle it at the callsite.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern comes direct from go/go-style/best-practices#test-helper-error-handling.

I like it, since it reduces clutter at the call site for what's essentially a failed precondition. But I can change it to return an error if you feel strongly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's good to know. I guess I'm always a bit weirded out by code that passes t around. But I suppose that's considered normal in Go.

@hiranya911 hiranya911 assigned rsgowman and unassigned hiranya911 Mar 9, 2020
Base automatically changed from rsgowman/bulk_get to dev May 20, 2020 20:48
@rsgowman rsgowman removed their assignment Mar 7, 2021
Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks pretty solid. Lets get rid of the CI/workflow stuff that's unrelated.

@@ -0,0 +1,105 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove any changes to Actions workflow configs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. (Must've been a bad merge)

// exists.
// TODO(rsgowman): This function was ported from node.js port; a number of tests
// there use this, but haven't been ported to go yet. Do so.
func deletePhoneNumberUser(t *testing.T, phoneNumber string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's good to know. I guess I'm always a bit weirded out by code that passes t around. But I suppose that's considered normal in Go.

t.Fatal(err)
}

err = client.DeleteUser(context.Background(), userRecord.UID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error check can be inlined here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@hiranya911 hiranya911 assigned rsgowman and unassigned hiranya911 Mar 16, 2021
@hiranya911 hiranya911 changed the title Add ability to link a federated id with the UpdateUser() method. feat(auth): Add ability to link a federated id with the UpdateUser() method. Mar 16, 2021
@rsgowman rsgowman requested a review from egilmorez March 17, 2021 13:24
@rsgowman rsgowman assigned egilmorez and unassigned rsgowman Mar 17, 2021
Copy link

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two public-facing comments (I think) look good, thanks!

return nil, err
}

// Although we don't really advertise it, we want to also handle linking of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that none of this comment gets parsed into the generated docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this shouldn't make it into the public facing docs.

@rsgowman rsgowman merged commit 33bf95d into dev Mar 23, 2021
@rsgowman rsgowman deleted the rsgowman/linkByFederatedId branch March 23, 2021 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants