Skip to content

Propagate customData in FirebaseError when the user is disabled. #6289

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 3 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: "[email protected]",
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: "[email protected]"
});

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