コード例 #1
0
        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
            }));
        }
コード例 #2
0
        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
            }));
        }
コード例 #3
0
 public void SaveTableNameCache(NameValueCollection nameValueCollection)
 {
     if (nameValueCollection != null && nameValueCollection.Count > 0)
     {
         var cacheKey   = GetTableNameNameValueCollectionDbCacheKey();
         var cacheValue = TranslateUtils.NameValueCollectionToString(nameValueCollection);
         DbCacheManager.RemoveAndInsert(cacheKey, cacheValue);
     }
 }
コード例 #4
0
ファイル: ServiceManager.cs プロジェクト: yankaics/cms-1
        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();
            }
        }
コード例 #5
0
        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;
        }
コード例 #6
0
 private static void SaveColumnsMap(NameValueCollection columnsMap)
 {
     DbCacheManager.RemoveAndInsert("SiteServer.BackgroundPages.Cms.BackgroundGatherDatabaseRuleAdd.TableMatchColumnsMap", TranslateUtils.NameValueCollectionToString(columnsMap));
 }