Skip to content

Commit 88517b5

Browse files
authored
Propagate customData in FirebaseError when the user is disabled. (#6289)
* Propagate customData in FireBaseError when the user is disabled. * unit test to verify customData upon user-disabled error. * Added changeset.
1 parent 71d5216 commit 88517b5

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.changeset/late-toys-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/auth': patch
3+
---
4+
5+
Propagate customData in FirebaseError when the user is disabled.

packages/auth/src/api/authentication/idp.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,34 @@ describe('api/authentication/signInWithIdp', () => {
8787
);
8888
expect(mock.calls[0].request).to.eql(request);
8989
});
90+
it('should handle user disabled errors and propagate email info', async () => {
91+
const response = {
92+
93+
error: {
94+
code: 400,
95+
message: ServerError.USER_DISABLED,
96+
errors: [
97+
{
98+
message: ServerError.USER_DISABLED
99+
}
100+
]
101+
}
102+
};
103+
104+
const mock = mockEndpoint(
105+
Endpoint.SIGN_IN_WITH_IDP,
106+
response,
107+
400
108+
);
109+
110+
await expect(signInWithIdp(auth, request))
111+
.to.be.rejectedWith(FirebaseError, 'auth/user-disabled')
112+
.eventually.with.deep.property('customData', {
113+
appName: 'test-app',
114+
_tokenResponse: response,
115+
116+
});
117+
118+
expect(mock.calls[0].request).to.eql(request);
119+
});
90120
});

packages/auth/src/api/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ export async function _performFetchWithErrorHandling<V>(
159159
);
160160
} else if (serverErrorCode === ServerError.EMAIL_EXISTS) {
161161
throw _makeTaggedError(auth, AuthErrorCode.EMAIL_EXISTS, json);
162+
} else if (serverErrorCode === ServerError.USER_DISABLED) {
163+
throw _makeTaggedError(auth, AuthErrorCode.USER_DISABLED, json);
162164
}
163165
const authError =
164166
errorMap[serverErrorCode as ServerError] ||

0 commit comments

Comments
 (0)