Skip to content

Catch invalid provider id error #1064

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 2 commits into from
Jul 30, 2018
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
3 changes: 3 additions & 0 deletions packages/auth/src/error_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ fireauth.authenum.Error = {
INVALID_PASSWORD: 'wrong-password',
INVALID_PERSISTENCE: 'invalid-persistence-type',
INVALID_PHONE_NUMBER: 'invalid-phone-number',
INVALID_PROVIDER_ID: 'invalid-provider-id',
INVALID_RECIPIENT_EMAIL: 'invalid-recipient-email',
INVALID_SENDER: 'invalid-sender',
INVALID_SESSION_INFO: 'invalid-verification-id',
Expand Down Expand Up @@ -294,6 +295,8 @@ fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PHONE_NUMBER] =
'phone number in a format that can be parsed into E.164 format. E.164 ' +
'phone numbers are written in the format [+][country code][subscriber ' +
'number including area code].';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PROVIDER_ID] =
'The specified provider ID is invalid.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_RECIPIENT_EMAIL] =
'The email corresponding to this action failed to send as the provided ' +
'recipient email address is invalid.';
Expand Down
5 changes: 5 additions & 0 deletions packages/auth/src/rpchandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ fireauth.RpcHandler.ServerError = {
INVALID_OOB_CODE: 'INVALID_OOB_CODE',
INVALID_PASSWORD: 'INVALID_PASSWORD',
INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
INVALID_PROVIDER_ID: 'INVALID_PROVIDER_ID',
INVALID_RECIPIENT_EMAIL: 'INVALID_RECIPIENT_EMAIL',
INVALID_SENDER: 'INVALID_SENDER',
INVALID_SESSION_INFO: 'INVALID_SESSION_INFO',
Expand Down Expand Up @@ -2244,6 +2245,10 @@ fireauth.RpcHandler.getDeveloperError_ =
errorMap[fireauth.RpcHandler.ServerError.MISSING_OOB_CODE] =
fireauth.authenum.Error.INTERNAL_ERROR;

// Get Auth URI errors:
errorMap[fireauth.RpcHandler.ServerError.INVALID_PROVIDER_ID] =
fireauth.authenum.Error.INVALID_PROVIDER_ID;

// Operations that require ID token in request:
errorMap[fireauth.RpcHandler.ServerError.CREDENTIAL_TOO_OLD_LOGIN_AGAIN] =
fireauth.authenum.Error.CREDENTIAL_TOO_OLD_LOGIN_AGAIN;
Expand Down
24 changes: 24 additions & 0 deletions packages/auth/test/rpchandler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5268,6 +5268,30 @@ function testGetAuthUri_success() {
}


/**
* Tests server side getAuthUri error.
*/
function testGetAuthUri_caughtServerError() {
var expectedUrl = 'https://www.googleapis.com/identitytoolkit/v3/relyin' +
'gparty/createAuthUri?key=apiKey';
var requestBody = {
'providerId': 'abc.com',
'continueUri': 'http://localhost/widget',
'customParameter': {}
};
var errorMap = {};
// All related server errors for getAuthUri.
errorMap[fireauth.RpcHandler.ServerError.INVALID_PROVIDER_ID] =
fireauth.authenum.Error.INVALID_PROVIDER_ID;

assertServerErrorsAreHandled(function() {
return rpcHandler.getAuthUri(
'abc.com',
'http://localhost/widget');
}, errorMap, expectedUrl, requestBody);
}


/**
* Tests successful getAuthUri request with Google provider and sessionId.
*/
Expand Down