Esempio n. 1
0
 public void CheckPassword(FormCollection collection)
 {
     if (!HttpContext.User.Identity.IsAuthenticated || CurrentUser == null)
     {
         RedirectToAction(ViewBag.BasePath + "Account/Login");//去登录
     }
     else
     {
         JsonObject json     = new JsonObject();
         string     password = collection["Password"];
         if (!string.IsNullOrWhiteSpace(password))
         {
             SiteIdentity SID = new SiteIdentity(CurrentUser.UserName);
             if (SID.TestPassword(password.Trim()) == 0)
             {
                 json.Accumulate("STATUS", "ERROR");
             }
             else
             {
                 json.Accumulate("STATUS", "OK");
             }
         }
         else
         {
             json.Accumulate("STATUS", "UNDEFINED");
         }
         Response.Write(json.ToString());
     }
 }
Esempio n. 2
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                SiteIdentity SID = new SiteIdentity(User.Identity.Name);
                if (SID.TestPassword(txtOldPassword.Text) == 0)
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text      = "原密码输入错误!";
                }
                else
                if (this.txtPassword.Text.Trim() != this.txtPassword1.Text.Trim())
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text      = "密码输入的不一致!请重试!";
                }
                else
                {
                    AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser       = new LTP.Accounts.Bus.User(user);

                    //currentUser.Password=AccountsPrincipal.EncryptPassword(txtPassword.Text);
                    currentUser.NonEncryptPasswordPassword = txtPassword.Text;
                    if (!currentUser.Update())
                    {
                        this.lblMsg.ForeColor = Color.Red;
                        this.lblMsg.Text      = "更新用户信息发生错误!";
                        //日志
                        //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri, "用户密码更新失败");
                    }
                    else
                    {
                        this.lblMsg.ForeColor = Color.Blue;
                        this.lblMsg.Text      = "用户信息更新成功!";
                        //日志
                        //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri, "用户密码更新成功");
                    }
                }
            }
        }
Esempio n. 3
0
        public ActionResult UserPass(string oldPassword, string newPassword, string confirmPassword)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));                                           //去登录
            }
            SiteIdentity SID  = new SiteIdentity(User.Identity.Name);
            JsonObject   json = new JsonObject();

            if (SID.TestPassword(oldPassword) == 0)
            {
                json.Put("Result", "Error");
                return(Json(json));
            }
            else
            {
                if (newPassword.Trim() != confirmPassword.Trim())
                {
                    json.Put("Result", "ConfirmError");
                    return(Json(json));
                }
                else
                {
                    YSWL.Accounts.Bus.User currentUser = CurrentUser;
                    if (!currentUser.SetPassword(CurrentUser.UserName, newPassword, MvcApplication.IsAutoConn))
                    {
                        json.Put("Result", "NO");
                        return(Json(json));
                    }
                    else
                    {
                        json.Put("Result", "OK");
                        return(Json(json));
                    }
                }
            }
        }
Esempio n. 4
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                SiteIdentity SID = new SiteIdentity(User.Identity.Name);
                if (SID.TestPassword(txtOldPassword.Text) == 0)
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text      = Resources.Site.ErrorPasswprdError;
                }
                else
                if (this.txtPassword.Text.Trim() != this.txtPassword1.Text.Trim())
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text      = Resources.Site.ErrorPasswprd;
                }
                else
                {
                    User currentUser = this.CurrentUser;

                    currentUser.Password = AccountsPrincipal.EncryptPassword(txtPassword.Text);

                    if (!currentUser.Update())
                    {
                        YSWL.Common.MessageBox.ShowFailTip(this, Resources.Site.TooltipUpdateError);
                        //日志
                        //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri,Resources.Site.TooltipUpdateFailPassword);
                    }
                    else
                    {
                        YSWL.Common.MessageBox.ShowSuccessTip(this, Resources.Site.TooltipSaveOK);
                        //日志
                        //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri,Resources.Site.TooltipUpdateSuccessfulPassword);
                    }
                }
            }
        }
Esempio n. 5
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                SiteIdentity SID = new SiteIdentity(User.Identity.Name);
                if (SID.TestPassword(txtOldPassword.Text) == 0)
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text      = "原密码输入错误!";
                }
                else
                if (this.txtPassword.Text.Trim() != this.txtPassword1.Text.Trim())
                {
                    this.lblMsg.ForeColor = Color.Red;
                    this.lblMsg.Text      = "密码输入的不一致!请重试!";
                }
                else
                {
                    AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser       = new LTP.Accounts.Bus.User(user);

                    currentUser.Password = AccountsPrincipal.EncryptPassword(txtPassword.Text);

                    if (!currentUser.Update())
                    {
                        this.lblMsg.ForeColor = Color.Red;
                        this.lblMsg.Text      = "更新用户信息发生错误!";
                    }
                    else
                    {
                        this.lblMsg.ForeColor = Color.Blue;
                        this.lblMsg.Text      = "用户信息更新成功!";
                    }
                }
            }
        }