Skip to content

Commit f86d8c9

Browse files
authored
Catch invalid provider id error (#1064)
1 parent 5c485dc commit f86d8c9

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

packages/auth/src/error_auth.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ fireauth.authenum.Error = {
147147
INVALID_PASSWORD: 'wrong-password',
148148
INVALID_PERSISTENCE: 'invalid-persistence-type',
149149
INVALID_PHONE_NUMBER: 'invalid-phone-number',
150+
INVALID_PROVIDER_ID: 'invalid-provider-id',
150151
INVALID_RECIPIENT_EMAIL: 'invalid-recipient-email',
151152
INVALID_SENDER: 'invalid-sender',
152153
INVALID_SESSION_INFO: 'invalid-verification-id',
@@ -294,6 +295,8 @@ fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PHONE_NUMBER] =
294295
'phone number in a format that can be parsed into E.164 format. E.164 ' +
295296
'phone numbers are written in the format [+][country code][subscriber ' +
296297
'number including area code].';
298+
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PROVIDER_ID] =
299+
'The specified provider ID is invalid.';
297300
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_RECIPIENT_EMAIL] =
298301
'The email corresponding to this action failed to send as the provided ' +
299302
'recipient email address is invalid.';

packages/auth/src/rpchandler.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ fireauth.RpcHandler.ServerError = {
207207
INVALID_OOB_CODE: 'INVALID_OOB_CODE',
208208
INVALID_PASSWORD: 'INVALID_PASSWORD',
209209
INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
210+
INVALID_PROVIDER_ID: 'INVALID_PROVIDER_ID',
210211
INVALID_RECIPIENT_EMAIL: 'INVALID_RECIPIENT_EMAIL',
211212
INVALID_SENDER: 'INVALID_SENDER',
212213
INVALID_SESSION_INFO: 'INVALID_SESSION_INFO',
@@ -2244,6 +2245,10 @@ fireauth.RpcHandler.getDeveloperError_ =
22442245
errorMap[fireauth.RpcHandler.ServerError.MISSING_OOB_CODE] =
22452246
fireauth.authenum.Error.INTERNAL_ERROR;
22462247

2248+
// Get Auth URI errors:
2249+
errorMap[fireauth.RpcHandler.ServerError.INVALID_PROVIDER_ID] =
2250+
fireauth.authenum.Error.INVALID_PROVIDER_ID;
2251+
22472252
// Operations that require ID token in request:
22482253
errorMap[fireauth.RpcHandler.ServerError.CREDENTIAL_TOO_OLD_LOGIN_AGAIN] =
22492254
fireauth.authenum.Error.CREDENTIAL_TOO_OLD_LOGIN_AGAIN;

packages/auth/test/rpchandler_test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5268,6 +5268,30 @@ function testGetAuthUri_success() {
52685268
}
52695269

52705270

5271+
/**
5272+
* Tests server side getAuthUri error.
5273+
*/
5274+
function testGetAuthUri_caughtServerError() {
5275+
var expectedUrl = 'https://www.googleapis.com/identitytoolkit/v3/relyin' +
5276+
'gparty/createAuthUri?key=apiKey';
5277+
var requestBody = {
5278+
'providerId': 'abc.com',
5279+
'continueUri': 'http://localhost/widget',
5280+
'customParameter': {}
5281+
};
5282+
var errorMap = {};
5283+
// All related server errors for getAuthUri.
5284+
errorMap[fireauth.RpcHandler.ServerError.INVALID_PROVIDER_ID] =
5285+
fireauth.authenum.Error.INVALID_PROVIDER_ID;
5286+
5287+
assertServerErrorsAreHandled(function() {
5288+
return rpcHandler.getAuthUri(
5289+
'abc.com',
5290+
'http://localhost/widget');
5291+
}, errorMap, expectedUrl, requestBody);
5292+
}
5293+
5294+
52715295
/**
52725296
* Tests successful getAuthUri request with Google provider and sessionId.
52735297
*/

0 commit comments

Comments
 (0)