Exemplo n.º 1
0
 private void GenerateRandomCode()
 {
     if (CDHelper.Config.EnableLoginAuhenCode == "true")
     {
         tbAuthCode2.Visible = true;
         Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 原始登录的方法
        /// </summary>
        /// <param name="loginName">本地用户名</param>
        /// <param name="password">本地用户的密码</param>
        /// <param name="checkPassword">是否校验密码</param>
        void LoginAction(string loginName, string password)
        {
            if (String.IsNullOrEmpty(loginName) || String.IsNullOrEmpty(loginName.Trim()))
            {
                ShowMessage("错误:用户名不能为空!");
                return;
            }

            if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(password.Trim()))
            {
                ShowMessage("错误:密码不能为空!");
                return;
            }

            if (GeneralConfigs.GetConfig().EnableLoginAuhenCode == "true" && this.CodeNumberTextBox.Text != Request.Cookies["AreYouHuman"].Value)
            {
                ShowMessage("错误:您输入的验证码不正确,请重新输入!");
                this.CodeNumberTextBox.Text           = "";
                Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode();
                return;
            }

            bool loginSuccess = false;

            if (CheckLocalAdministrator(loginName))
            {
                if (CDHelper.AdminPasswordIsValid(password))
                {
                    Security.SetAccountID(We7Helper.EmptyGUID);
                    loginSuccess = true;
                    SSOLogin(loginName, password);
                }
                else
                {
                    ShowMessage("无法登录,原因:密码错误!");
                    return;
                }
            }
            else
            {
                string[] result = AccountHelper.Login(loginName, password);
                if (result[0] == "false")
                {
                    ShowMessage("无法登录,原因:" + result[1]);
                    return;
                }
                else
                {
                    SSOLogin(loginName, password);
                }
            }

            GoWhere();
        }