-
Notifications
You must be signed in to change notification settings - Fork 264
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
Conversation
And inline the implementation.
This reverts commit ae498f7.
* chore: Added Actions-based release workflow * Set GOPATH * Fixed working directory for tests * Decrypting credentials into the testdata directory * Added preflight and post check scripts
Note the diffbase. I'll merge+retarget to dev once the bulk_get stuff lands. |
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.
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( |
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.
You can use errors.New()
when the error message doesn't contain any formatting directives.
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.
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' " + |
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.
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.
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.
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) { |
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.
We really ought to stop passing t
to helper functions. Instead return an error from this function, and handle it at the callsite.
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.
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.
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.
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.
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.
Implementation looks pretty solid. Lets get rid of the CI/workflow stuff that's unrelated.
@@ -0,0 +1,105 @@ | |||
|
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.
Please remove any changes to Actions workflow configs.
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.
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) { |
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.
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.
integration/auth/user_mgt_test.go
Outdated
t.Fatal(err) | ||
} | ||
|
||
err = client.DeleteUser(context.Background(), userRecord.UID) |
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.
Error check can be inlined here.
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.
Done.
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 👍
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 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 |
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.
Assuming that none of this comment gets parsed into the generated docs.
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.
No, this shouldn't make it into the public facing docs.
No description provided.