コード例 #1
0
        public string UpdateCloseAccount([FromBody] JObject value)
        {
            try
            {
                var userModel = (User)RouteData.Values[ParseDataKeyApi.KEY_PASS_DATA_USER_MODEL];

                if (
                    !value.ContainsKey(ParseDataKeyApi.KEY_SECURITY_UPDATE_CLOSE_ACCOUNT_STATUS) ||
                    !value.ContainsKey(ParseDataKeyApi.KEY_SECURITY_UPDATE_CLOSE_ACCOUNT_PASSWORD))
                {
                    return(HelpersApi.CreateDataError(MessageApiError.PARAM_INVALID + 1));
                }

                var code = "";
                if (value.ContainsKey(ParseDataKeyApi.KEY_SECURITY_UPDATE_CLOSE_ACCOUNT_CODE))
                {
                    code = value[ParseDataKeyApi.KEY_SECURITY_UPDATE_CLOSE_ACCOUNT_CODE].ToString();
                }

                var status = value[ParseDataKeyApi.KEY_SECURITY_UPDATE_CLOSE_ACCOUNT_STATUS];

                if (!int.TryParse((string)status, out var outStatus))
                {
                    return(HelpersApi.CreateDataError(MessageApiError.PARAM_INVALID + 2));
                }

                var password = value[ParseDataKeyApi.KEY_SECURITY_UPDATE_CLOSE_ACCOUNT_PASSWORD].ToString();

                if (!HelpersApi.ValidateSecondPass(password))
                {
                    return(HelpersApi.CreateDataError(MessageApiError.PARAM_INVALID + 3));
                }

                if (userModel.IsLockScreen != 0)
                {
                    if (!CommonHelper.Md5(password).Equals(userModel.SecondPassword))
                    {
                        return new ReturnObject
                               {
                                   Status  = Status.STATUS_ERROR,
                                   Message = "Pass is invalid"
                               }
                    }
                    .ToJson();
                }