-
Notifications
You must be signed in to change notification settings - Fork 407
feat(auth): Implement getUserByProviderId #769
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
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa9934b
Implement getUserByFederatedId()
rsgowman b7458e2
getAccountByFederatedId -> getAccountByProviderId
rsgowman 4609191
review feedback
rsgowman a59ef60
review feedback 2
rsgowman e9197f9
review feedback 3
rsgowman 8dbdd6e
Merge remote-tracking branch 'origin/master' into rsgowman/getAccount…
rsgowman 40e0060
review nits
rsgowman 1cb1178
lint
rsgowman f6c19a9
api-extractor
rsgowman 8440262
Merge remote-tracking branch 'origin/master' into rsgowman/getAccount…
rsgowman 88c5f5c
Merge remote-tracking branch 'origin/master' into rsgowman/getAccount…
rsgowman 655b20f
Add a few extra tests
rsgowman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Implement getUserByFederatedId()
- Loading branch information
commit fa9934b62420fb4ef581c5d0bf2b6f2dd3827e9f
There are no files selected for viewing
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
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
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
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 |
|---|---|---|
|
|
@@ -66,6 +66,7 @@ const mockUserData = { | |
| displayName: 'Random User ' + newUserUid, | ||
| photoURL: 'http://www.example.com/' + newUserUid + '/photo.png', | ||
| disabled: false, | ||
|
|
||
| }; | ||
| const actionCodeSettings = { | ||
| url: 'http://localhost/?a=1&b=2#c=3', | ||
|
|
@@ -168,6 +169,44 @@ describe('admin.auth', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('getUserByFederatedId() returns a user record with the matching federated id', async () => { | ||
| // TODO(rsgowman): Once we can link a provider id with a user, just do that | ||
| // here instead of creating a new user. | ||
| const importUser: admin.auth.UserImportRecord = { | ||
| uid: 'uid', | ||
| email: '[email protected]', | ||
| phoneNumber: '+15555550000', | ||
| emailVerified: true, | ||
| disabled: false, | ||
| metadata: { | ||
| lastSignInTime: 'Thu, 01 Jan 1970 00:00:00 UTC', | ||
| creationTime: 'Thu, 01 Jan 1970 00:00:00 UTC', | ||
| toJSON: () => { throw new Error('Unimplemented'); }, | ||
| }, | ||
| providerData: [{ | ||
| displayName: 'User Name', | ||
| email: '[email protected]', | ||
| phoneNumber: '+15555550000', | ||
| photoURL: 'http://example.com/user', | ||
| toJSON: () => { throw new Error('Unimplemented'); }, | ||
| providerId: 'google.com', | ||
| uid: 'google_uid', | ||
| }], | ||
| }; | ||
|
|
||
| await safeDelete(importUser.uid); | ||
hiranya911 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await admin.auth().importUsers([importUser]); | ||
|
|
||
| try { | ||
| await admin.auth().getUserByFederatedId('google.com', 'google_uid') | ||
| .then((userRecord) => { | ||
| expect(userRecord.uid).to.equal(importUser.uid); | ||
| }); | ||
| } finally { | ||
| await safeDelete(importUser.uid); | ||
| } | ||
| }); | ||
|
|
||
| it('listUsers() returns up to the specified number of users', () => { | ||
| const promises: Array<Promise<admin.auth.UserRecord>> = []; | ||
| uids.forEach((uid) => { | ||
|
|
@@ -356,6 +395,11 @@ describe('admin.auth', () => { | |
| .should.eventually.be.rejected.and.have.property('code', 'auth/user-not-found'); | ||
| }); | ||
|
|
||
| it('getUserByFederatedId() fails when called with a non-existing federated id', () => { | ||
| return admin.auth().getUserByFederatedId('google.com', nonexistentUid) | ||
| .should.eventually.be.rejected.and.have.property('code', 'auth/user-not-found'); | ||
| }); | ||
|
|
||
| it('updateUser() fails when called with a non-existing UID', () => { | ||
| return admin.auth().updateUser(nonexistentUid, { | ||
| emailVerified: true, | ||
|
|
||
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.
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.
nit: remove the blank line
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.