Esempio n. 1
0
        public virtual IHttpActionResult SendValidateCode(string from, string countryCode, string to)
        {
            SMSClient smsClient = new SMSClient();
            var       response  = smsClient.SendVerify(from, countryCode + to);

            if (response.Status == "0")
            {
                return(Ok(new { requestId = response.RequestId }));
            }
            else
            {
                throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.SMSSendCodeError, response.ErrorText);
            }
        }
Esempio n. 2
0
        public async virtual Task <IHttpActionResult> AuthUserSendCode(string userName, string token, [FromBody] AuthUserSendCodeModel authUserSendCodeModel)
        {
            var tenantId    = authUserSendCodeModel.TenantId;
            var communityId = authUserSendCodeModel.CommunityId;
            var phone       = authUserSendCodeModel.Phone;

            base.AuthUser();
            using (CurrentUnitOfWork.SetTenantId(tenantId))
            {
                var homeOwerUser = await _homeOwerUserManager.GetHomeOwerUserByUserName(userName);

                var homeOwer = await _homeOwerManager.GetHomeOwerByNameAndPhoneAndCommunityId(communityId, phone);

                //if (homeOwerUser == null)
                //{
                //    throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.HomeOwerUserNotExists);
                //}
                if (homeOwer == null)
                {
                    throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.HomeOwerNotExists);
                }
                if (homeOwer.Status == EHomeOwerStatusType.Done)
                {
                    throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.HomeOwerUserIsExists);
                }
                else
                {
                    //发送验证码
                    SMSClient smsClient        = new SMSClient();
                    var       phoneCountryCode = await SettingManager.GetSettingValueAsync(AppSettings.UserManagement.PhoneCountryCode);

                    var response = smsClient.SendVerify("Localink", phoneCountryCode + homeOwer.Phone);
                    if (response.Status == "0")
                    {
                        homeOwer.ValidateCode = response.RequestId;
                        await _homeOwerManager.UpdateAsync(homeOwer);

                        return(Ok());
                    }
                    else
                    {
                        throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.SMSSendCodeError, response.ErrorText);
                    }
                }
            }
        }