Esempio n. 1
0
        void changePassword(string loginName, string password, string newPassword)
        {
            if (AccountID == We7Helper.EmptyGUID && String.Compare(loginName, SiteConfigs.GetConfig().AdministratorName, true) == 0)
            {
                if (CDHelper.AdminPasswordIsValid(password))
                {
                    SiteConfigInfo si       = SiteConfigs.GetConfig();
                    bool           isHashed = si.IsPasswordHashed;
                    if (isHashed != IsHashedPasswordCheckBox.Checked)
                    {
                        si.IsPasswordHashed = IsHashedPasswordCheckBox.Checked;
                    }
                    if (IsHashedPasswordCheckBox.Checked)
                    {
                        si.AdministratorKey = Security.Encrypt(newPassword);
                    }
                    else
                    {
                        si.AdministratorKey = newPassword;
                    }

                    SiteConfigs.SaveConfig(si);
                    //CDHelper.UpdateSystemInformation(si);

                    ShowMessage("您的密码已修改成功。");
                }
                else
                {
                    ShowMessage("对不起,您输入的旧密码不正确!");
                }
            }
            else
            {
                Account act = AccountHelper.GetAccountByLoginName(loginName);
                if (act == null)
                {
                    ShowMessage("指定的用户不存在。");
                }
                else if (!AccountHelper.IsValidPassword(act, password))
                {
                    ShowMessage("对不起,您输入的旧密码不正确!");
                }
                else if (act.State != 1)
                {
                    ShowMessage("该帐户不可用。");
                }
                else
                {
                    act.IsPasswordHashed = IsHashedPasswordCheckBox.Checked;
                    AccountHelper.UpdatePassword(act, newPassword);

                    //记录日志
                    string content = string.Format("修改了“{0}”的密码", act.LoginName);
                    AddLog("修改密码", content);

                    ShowMessage("您的密码已修改成功。");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 验证用户
        /// </summary>
        void Authenticate()
        {
            if (String.Compare(LoginName, SiteConfigs.GetConfig().AdministratorName, false) == 0)
            {
                if (CDHelper.AdminPasswordIsValid(Password))
                {
                    Security.SetAccountID(We7Helper.EmptyGUID);
                    UserName = SiteConfigs.GetConfig().AdministratorName;
                    IsSignIn = true;
                }
                else
                {
                    IsSignIn = false;
                    Message  = "密码错误";
                }
            }
            else
            {
                if (Request["Authenticator"] != null && Request["accountID"] != null)
                {
                    SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current);
                    string     actID      = ssoRequest.AccountID;
                    if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID))
                    {
                        Security.SetAccountID(actID, IsPersist);
                        UserName = ssoRequest.UserName;
                        IsSignIn = true;
                    }
                    else if (Request["message"] != null)
                    {
                        Message  = Request["message"];
                        IsSignIn = false;
                        return;
                    }
                }
                else
                {
                    IAccountHelper AccountHelper = AccountFactory.CreateInstance();

                    string[] result = AccountHelper.Login(LoginName, Password);

                    if (result[0] == "false")
                    {
                        Message  = result[1];
                        IsSignIn = false;
                    }
                    else
                    {
                        IsSignIn = true;
                        UserName = AccountHelper.GetAccount(result[1], new string[] { "LoginName" }).LoginName;
                        Response.Redirect(ReturnUrl);
                    }
                }
            }
        }
Esempio n. 3
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();
        }