public IHttpActionResult Main() { var body = new RequestBody(); var account = body.GetPostString("account"); var mobile = BaiRongDataProvider.UserDao.GetMobileByAccount(account); var isSuccess = false; string errorMessage; if (string.IsNullOrEmpty(mobile) || !StringUtils.IsMobile(mobile)) { errorMessage = "账号对应的用户未设置手机号码"; } else { var code = StringUtils.GetRandomInt(1111, 9999); DbCacheManager.RemoveAndInsert($"SiteServer.API.Controllers.Users.SendSms.{mobile}.Code", code.ToString()); isSuccess = SmsManager.SendVerify(mobile, code, ConfigManager.UserConfigInfo.FindPasswordSmsTplId, out errorMessage); } return(Ok(new { IsSuccess = isSuccess, Mobile = mobile, ErrorMessage = errorMessage })); }
public IHttpActionResult Main() { var body = new RequestBody(); var mobile = body.GetPostString("mobile"); var password = body.GetPostString("password"); var isSms = false; var isRegister = false; var errorMessage = string.Empty; if (ConfigManager.UserConfigInfo.RegisterVerifyType == EUserVerifyType.Mobile) { var code = StringUtils.GetRandomInt(1111, 9999); DbCacheManager.RemoveAndInsert($"SiteServer.API.Controllers.Users.SendSms.{mobile}.Code", code.ToString()); isSms = SmsManager.SendVerify(mobile, code, ConfigManager.UserConfigInfo.RegisterSmsTplId, out errorMessage); } if (!isSms) { var userInfo = new UserInfo { UserName = mobile, Mobile = mobile, Password = password }; isRegister = BaiRongDataProvider.UserDao.Insert(userInfo, PageUtils.GetIpAddress(), out errorMessage); } return(Ok(new { IsSms = isSms, IsRegister = isRegister, ErrorMessage = errorMessage })); }
public void SaveTableNameCache(NameValueCollection nameValueCollection) { if (nameValueCollection != null && nameValueCollection.Count > 0) { var cacheKey = GetTableNameNameValueCollectionDbCacheKey(); var cacheValue = TranslateUtils.NameValueCollectionToString(nameValueCollection); DbCacheManager.RemoveAndInsert(cacheKey, cacheValue); } }
public static void SetServiceOnline(bool isOnline) { if (isOnline) { var cacheValue = CacheManager.GetCache(CacheKeyStatus) as string; if (TranslateUtils.ToBool(cacheValue)) { return; } DbCacheManager.RemoveAndInsert(CacheKeyStatus, DateTime.Now.ToString(CultureInfo.InvariantCulture)); CacheManager.SetCache(CacheKeyStatus, true.ToString(), DateTime.Now.AddMinutes(10)); } else { DbCacheManager.GetValueAndRemove(CacheKeyStatus); ClearStatusCache(); ClearIsPendingCreateCache(); ClearTaskCache(); } }
public void Account_OnClick(object sender, EventArgs e) { var account = TbAccount.Text; if (FileConfigManager.Instance.IsValidateCode) { if (!_vcManager.IsCodeValid(TbValidateCode.Text)) { LtlMessage.Text = GetMessageHtml("验证码不正确,请重新输入!", true); return; } } string userName = null; if (StringUtils.IsMobile(account)) { userName = BaiRongDataProvider.AdministratorDao.GetUserNameByMobile(account); } else if (StringUtils.IsEmail(account)) { userName = BaiRongDataProvider.AdministratorDao.GetUserNameByEmail(account); } else { if (BaiRongDataProvider.AdministratorDao.IsUserNameExists(account)) { userName = account; } } if (string.IsNullOrEmpty(userName)) { LtlMessage.Text = GetMessageHtml("找回密码错误,输入的账号不存在", true); return; } var mobile = BaiRongDataProvider.AdministratorDao.GetMobileByUserName(account); if (string.IsNullOrEmpty(mobile) || !StringUtils.IsMobile(mobile)) { LtlMessage.Text = GetMessageHtml("找回密码错误,账号对应的管理员未设置手机号码", true); return; } string errorMessage; var code = StringUtils.GetRandomInt(1111, 9999); DbCacheManager.RemoveAndInsert($"BaiRong.BackgroundPages.FrameworkFindPwd.{userName}.Code", code.ToString()); var isSend = SmsManager.SendVerify(mobile, code, ConfigManager.SystemConfigInfo.FindPasswordSmsTplId, out errorMessage); if (!isSend) { LtlMessage.Text = GetMessageHtml($"找回密码错误:{errorMessage}", true); return; } ViewState["UserName"] = userName; LtlPageTitle.Text = "验证手机"; LtlMessage.Text = GetMessageHtml($"短信验证码已发送至:{mobile.Substring(0, 3) + "*****" + mobile.Substring(8)}", true); PhStepAccount.Visible = false; PhStepSmsCode.Visible = true; PhStepChangePassword.Visible = false; }
private static void SaveColumnsMap(NameValueCollection columnsMap) { DbCacheManager.RemoveAndInsert("SiteServer.BackgroundPages.Cms.BackgroundGatherDatabaseRuleAdd.TableMatchColumnsMap", TranslateUtils.NameValueCollectionToString(columnsMap)); }