public async virtual Task <IHttpActionResult> AuthUserValidateCode(string userName, string token, [FromBody] AuthUserValidateCodeModel authUserValidateCodeModel) { var tenantId = authUserValidateCodeModel.TenantId; var phone = authUserValidateCodeModel.Phone; var communityId = authUserValidateCodeModel.CommunityId; var code = authUserValidateCodeModel.Code; 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); } else if (homeOwer.Status == EHomeOwerStatusType.Done) { throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.HomeOwerUserIsExists); } else { //验证验证码是否正确 SMSClient smsClient = new SMSClient(); var response = smsClient.Verify(homeOwer.ValidateCode, code); if (response.Status == "0") { homeOwerUser.HomeOwerId = homeOwer.Id; homeOwerUser.CommunityId = homeOwer.CommunityId; homeOwerUser.TenantId = tenantId; homeOwer.ValidateCode = string.Empty; homeOwer.Status = EHomeOwerStatusType.Waiting; await _homeOwerUserManager.UpdateAsync(homeOwerUser); await _homeOwerManager.UpdateAsync(homeOwer); return(Ok(new { HomeOwer = AutoMapper.Mapper.Map <HomeOwerDto>(homeOwer), Community = AutoMapper.Mapper.Map <CommunityDto>(homeOwer.FlatNumbers.First().Building.Community) })); } else { throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.ValidateCodeError); } } } }
public virtual IHttpActionResult ValidateCode(string requestId, string code) { SMSClient smsClient = new SMSClient(); var response = smsClient.Verify(requestId, code); if (response.Status == "0") { return(Ok()); } else { throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.SMSSendCodeError, response.ErrorText); } }