Skip to content

Commit

Permalink
Propagate customData in FirebaseError when the user is disabled. (#6289)
Browse files Browse the repository at this point in the history
* Propagate customData in FireBaseError when the user is disabled.

* unit test to verify customData upon user-disabled error.

* Added changeset.
  • Loading branch information
prameshj committed May 26, 2022
1 parent 71d5216 commit 88517b5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-toys-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/auth': patch
---

Propagate customData in FirebaseError when the user is disabled.
30 changes: 30 additions & 0 deletions packages/auth/src/api/authentication/idp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,34 @@ describe('api/authentication/signInWithIdp', () => {
);
expect(mock.calls[0].request).to.eql(request);
});
it('should handle user disabled errors and propagate email info', async () => {
const response = {
email: "test123@gmail.com",
error: {
code: 400,
message: ServerError.USER_DISABLED,
errors: [
{
message: ServerError.USER_DISABLED
}
]
}
};

const mock = mockEndpoint(
Endpoint.SIGN_IN_WITH_IDP,
response,
400
);

await expect(signInWithIdp(auth, request))
.to.be.rejectedWith(FirebaseError, 'auth/user-disabled')
.eventually.with.deep.property('customData', {
appName: 'test-app',
_tokenResponse: response,
email: "test123@gmail.com"
});

expect(mock.calls[0].request).to.eql(request);
});
});
2 changes: 2 additions & 0 deletions packages/auth/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export async function _performFetchWithErrorHandling<V>(
);
} else if (serverErrorCode === ServerError.EMAIL_EXISTS) {
throw _makeTaggedError(auth, AuthErrorCode.EMAIL_EXISTS, json);
} else if (serverErrorCode === ServerError.USER_DISABLED) {
throw _makeTaggedError(auth, AuthErrorCode.USER_DISABLED, json);
}
const authError =
errorMap[serverErrorCode as ServerError] ||
Expand Down

0 comments on commit 88517b5

Please sign in to comment.