示例#1
0
文件: PageLogin.cs 项目: zr53722/cms
        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.Validate(account, password, false, 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(PageInitialization.GetRedirectUrl());                       // 跳转到系统初始化页面
        }
示例#2
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (!string.IsNullOrEmpty(_message))
            {
                if (messageCtrl != null)
                {
                    messageCtrl.IsShowImmidiatary = true;
                    messageCtrl.MessageType       = _messageType;
                    messageCtrl.Content           = _message;
                }
                else
                {
                    MessageUtils.SaveMessage(_messageType, _message);
                }
            }

            base.Render(writer);

            if (!IsAccessable && !IsSinglePage)
            {
                writer.Write($@"<script type=""text/javascript"">
if (window.top.location.href.toLowerCase().indexOf(""main.aspx"") == -1){{
	window.top.location.href = ""{PageInitialization.GetRedirectUrl()}"";
}}
</script>");
            }

            if (!string.IsNullOrEmpty(_scripts))
            {
                writer.Write(@"<script type=""text/javascript"">{0}</script>", _scripts);
            }
        }
示例#3
0
文件: BasePage.cs 项目: zr53722/cms
        protected override void Render(HtmlTextWriter writer)
        {
            if (!string.IsNullOrEmpty(_message))
            {
                MessageUtils.SaveMessage(_messageType, _message);
            }

            base.Render(writer);

            if (!IsAccessable && !IsSinglePage) // 页面不能直接访问且不是单页,需要加一段框架检测代码,检测页面是否运行在框架内
            {
                writer.Write($@"<script type=""text/javascript"">
if (window.top.location.href.toLowerCase().indexOf(""main.aspx"") == -1){{
	window.top.location.href = ""{PageInitialization.GetRedirectUrl()}"";
}}
</script>");
            }

            if (!string.IsNullOrEmpty(_scripts))
            {
                writer.Write($@"<script type=""text/javascript"">{_scripts}</script>");
            }
        }