Пример #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var account  = TbAccount.Text;
            var password = TbPassword.Text;

            if (!_vcManager.IsCodeValid(TbValidateCode.Text)) // 检测验证码是否正确
            {
                LtlMessage.Text = GetMessageHtml("验证码不正确,请重新输入!");
                return;
            }

            string userName;
            string errorMessage;

            if (!DataProvider.AdministratorDao.ValidateAccount(account, password, out userName, out errorMessage)) // 检测密码是否正确
            {
                LogUtils.AddAdminLog(userName, "后台管理员登录失败");
                DataProvider.AdministratorDao.UpdateLastActivityDateAndCountOfFailedLogin(userName); // 记录最后登录时间、失败次数+1
                LtlMessage.Text = GetMessageHtml(errorMessage);                                      // 把错误信息显示在页面上
                return;
            }

            DataProvider.AdministratorDao.UpdateLastActivityDateAndCountOfLogin(userName); // 记录最后登录时间、失败次数清零
            AuthRequest.AdminLogin(userName);                                              // 写Cookie并记录管理员操作日志
            PageUtils.Redirect(PageUtils.GetAdminDirectoryUrl(string.Empty));              // 跳转到登录成功的后台页
        }
Пример #2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var account  = TbAccount.Text;
            var password = TbPassword.Text;

            if (FileConfigManager.Instance.IsValidateCode)
            {
                if (!_vcManager.IsCodeValid(TbValidateCode.Text))
                {
                    LtlMessage.Text = GetMessageHtml("验证码不正确,请重新输入!");
                    return;
                }
            }

            string userName;
            string errorMessage;

            if (!BaiRongDataProvider.AdministratorDao.ValidateAccount(account, password, out userName, out errorMessage))
            {
                LogUtils.AddAdminLog(userName, "后台管理员登录失败");
                BaiRongDataProvider.AdministratorDao.UpdateLastActivityDateAndCountOfFailedLogin(userName);
                LtlMessage.Text = GetMessageHtml(errorMessage);
                return;
            }

            BaiRongDataProvider.AdministratorDao.UpdateLastActivityDateAndCountOfLogin(userName);
            Body.AdministratorLogin(userName);
            string url = PageUtils.GetAdminDirectoryUrl(string.Empty);

            PageUtils.Redirect(url);
        }
Пример #3
0
        public void Account_OnClick(object sender, EventArgs e)
        {
            var account = TbAccount.Text;

            if (!_vcManager.IsCodeValid(TbValidateCode.Text))
            {
                LtlMessage.Text = GetMessageHtml("验证码不正确,请重新输入!", true);
                return;
            }

            string userName = null;

            if (StringUtils.IsMobile(account))
            {
                userName = DataProvider.AdministratorDao.GetUserNameByMobile(account);
            }
            else if (StringUtils.IsEmail(account))
            {
                userName = DataProvider.AdministratorDao.GetUserNameByEmail(account);
            }
            else
            {
                if (DataProvider.AdministratorDao.IsAdminNameExists(account))
                {
                    userName = account;
                }
            }

            if (string.IsNullOrEmpty(userName))
            {
                LtlMessage.Text = GetMessageHtml("找回密码错误,输入的账号不存在", true);
                return;
            }

            var mobile = DataProvider.AdministratorDao.GetMobileByUserName(account);

            if (string.IsNullOrEmpty(mobile) || !StringUtils.IsMobile(mobile))
            {
                LtlMessage.Text = GetMessageHtml("找回密码错误,账号对应的管理员未设置手机号码", true);
                return;
            }

            string errorMessage;
            var    code = StringUtils.GetRandomInt(1111, 9999);

            CacheDbUtils.RemoveAndInsert($"BaiRong.BackgroundPages.FrameworkFindPwd.{userName}.Code", code.ToString());
            var isSend = SmsManager.SendCode(mobile, code, ConfigManager.SystemConfigInfo.AdminFindPasswordSmsTplId, 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;
        }