Skip to content

added admin_only_operation error #1707

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 1 commit into from
Apr 18, 2019
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
9 changes: 6 additions & 3 deletions packages/auth/src/error_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fireauth.AuthError.ERROR_CODE_PREFIX = 'auth/';
* @enum {string}
*/
fireauth.authenum.Error = {
ADMIN_ONLY_OPERATION: 'admin-restricted-operation',
ARGUMENT_ERROR: 'argument-error',
APP_NOT_AUTHORIZED: 'app-not-authorized',
APP_NOT_INSTALLED: 'app-not-installed',
Expand Down Expand Up @@ -198,6 +199,8 @@ fireauth.authenum.Error = {
* @private {!Object<string, string>}
*/
fireauth.AuthError.MESSAGES_ = {};
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.ADMIN_ONLY_OPERATION] =
'This operation is restricted to administrators only.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.ARGUMENT_ERROR] = '';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.APP_NOT_AUTHORIZED] =
'This app, identified by the domain where it\'s hosted, is not ' +
Expand Down Expand Up @@ -277,9 +280,6 @@ fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_CERT_HASH] =
'The SHA-1 certificate hash provided is invalid.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_IDP_RESPONSE] =
'The supplied auth credential is malformed or has expired.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PERSISTENCE] =
'The specified persistence type is invalid. It can only be local, ' +
'session or none.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_MESSAGE_PAYLOAD] =
'The email template corresponding to this action contains invalid charac' +
'ters in its message. Please fix by going to the Auth email templates se' +
Expand All @@ -298,6 +298,9 @@ fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_OOB_CODE] =
'expired, or has already been used.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PASSWORD] =
'The password is invalid or the user does not have a password.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PERSISTENCE] =
'The specified persistence type is invalid. It can only be local, ' +
'session or none.';
fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PHONE_NUMBER] =
'The format of the phone number provided is incorrect. Please enter the ' +
'phone number in a format that can be parsed into E.164 format. E.164 ' +
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 @@ -184,6 +184,7 @@ fireauth.RpcHandler.HttpMethod = {
* @enum {string}
*/
fireauth.RpcHandler.ServerError = {
ADMIN_ONLY_OPERATION: 'ADMIN_ONLY_OPERATION',
CAPTCHA_CHECK_FAILED: 'CAPTCHA_CHECK_FAILED',
CORS_UNSUPPORTED: 'CORS_UNSUPPORTED',
CREDENTIAL_MISMATCH: 'CREDENTIAL_MISMATCH',
Expand Down Expand Up @@ -2432,6 +2433,10 @@ fireauth.RpcHandler.getDeveloperError_ =
errorMap[fireauth.RpcHandler.ServerError.INVALID_CERT_HASH] =
fireauth.authenum.Error.INVALID_CERT_HASH;

// User actions (sign-up or deletion) disabled errors.
errorMap[fireauth.RpcHandler.ServerError.ADMIN_ONLY_OPERATION] =
fireauth.authenum.Error.ADMIN_ONLY_OPERATION;

// Override errors set in the custom map.
var customErrorMap = opt_customErrorMap || {};
goog.object.extend(errorMap, customErrorMap);
Expand Down
4 changes: 4 additions & 0 deletions packages/auth/test/rpchandler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2800,6 +2800,8 @@ function testCreateAccount_serverCaughtError() {
fireauth.authenum.Error.OPERATION_NOT_ALLOWED;
errorMap[fireauth.RpcHandler.ServerError.WEAK_PASSWORD] =
fireauth.authenum.Error.WEAK_PASSWORD;
errorMap[fireauth.RpcHandler.ServerError.ADMIN_ONLY_OPERATION] =
fireauth.authenum.Error.ADMIN_ONLY_OPERATION;

assertServerErrorsAreHandled(function() {
return rpcHandler.createAccount(email, password);
Expand Down Expand Up @@ -2894,6 +2896,8 @@ function testDeleteAccount_serverCaughtError() {
fireauth.authenum.Error.TOKEN_EXPIRED;
errorMap[fireauth.RpcHandler.ServerError.USER_DISABLED] =
fireauth.authenum.Error.USER_DISABLED;
errorMap[fireauth.RpcHandler.ServerError.ADMIN_ONLY_OPERATION] =
fireauth.authenum.Error.ADMIN_ONLY_OPERATION;

assertServerErrorsAreHandled(function() {
return rpcHandler.deleteAccount('ID_TOKEN');
Expand Down