From: Dunrong Huang Date: Wed, 23 Dec 2015 13:42:28 +0000 (+0800) Subject: rgw: add a new error code for email conflict X-Git-Tag: v10.0.3~107^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c22731698cab7962f3c62934a37d422973ef157f;p=ceph.git rgw: add a new error code for email conflict From http://docs.ceph.com/docs/master/radosgw/adminops/ when provided email address exists, rgw should return EmailExists rather than UserAlreadyExists Signed-off-by: Dunrong Huang --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index c40f0b40ac3..86631ada912 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -156,6 +156,7 @@ using ceph::crypto::MD5; #define ERR_MALFORMED_XML 2029 #define ERR_USER_EXIST 2030 #define ERR_NOT_SLO_MANIFEST 2031 +#define ERR_EMAIL_EXIST 2032 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 #define ERR_NOT_IMPLEMENTED 2201 diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h index 7750d136c8e..1291409400c 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -51,6 +51,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = { { ETIMEDOUT, 408, "RequestTimeout" }, { EEXIST, 409, "BucketAlreadyExists" }, { ERR_USER_EXIST, 409, "UserAlreadyExists" }, + { ERR_EMAIL_EXIST, 409, "EmailExists" }, { ENOTEMPTY, 409, "BucketNotEmpty" }, { ERR_PRECONDITION_FAILED, 412, "PreconditionFailed" }, { ERANGE, 416, "InvalidRange" }, diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 5063cd0ccfc..72cbcbd21b2 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -1836,12 +1836,15 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) if (op_state.found_by_email) { set_err_msg(err_msg, "email: " + user_email + " exists"); + ret = -ERR_EMAIL_EXIST; } else if (op_state.found_by_key) { set_err_msg(err_msg, "duplicate key provided"); + ret = -EEXIST; } else { set_err_msg(err_msg, "user: " + op_state.user_id.to_str() + " exists"); + ret = -EEXIST; } - return -EEXIST; + return ret; } // fail if the user_info has already been populated @@ -2066,7 +2069,7 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) ret = rgw_get_user_info_by_email(store, op_email, duplicate_check); if (ret >= 0 && duplicate_check.user_id.compare(user_id) != 0) { set_err_msg(err_msg, "cannot add duplicate email"); - return -EEXIST; + return -ERR_EMAIL_EXIST; } } user_info.user_email = op_email;