Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //check input
            if (DataValidation.IsEmpty(txtOriginalPassword.Text))
            {
                SetMessage(GetMessage("E00113"));
                txtOriginalPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtNewPassword.Text))
            {
                SetMessage(GetMessage("E00114"));
                txtNewPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00115"));
                txtConfirmedPassword.Focus();
                return;
            }

            if (!DataValidation.IsEqual(txtNewPassword.Text, txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00116"));
                txtNewPassword.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator admin = new Johnny.CMS.BLL.Access.Administrator();
            string strPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOriginalPassword.Text, "MD5");

            //check old password
            if (!admin.CheckLogin(DataConvert.GetString(Session["UserName"]), strPwd))
            {
                SetMessage(GetMessage("E00117"));
                txtOriginalPassword.Focus();
                return;
            }

            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
            model.AdminId = DataConvert.GetInt32(Session["UserId"]);
            model.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPassword.Text, "MD5");
            model.UpdatedTime = System.DateTime.Now;
            model.UpdatedById = DataConvert.GetInt32(Session["UserId"]);
            model.UpdatedByName = DataConvert.GetString(Session["UserName"]);
            admin.ResetPassword(model);
            SetMessage(GetMessage("E00118"));
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //check input
            if (DataValidation.IsEmpty(txtOriginalPassword.Text))
            {
                SetMessage(GetMessage("E00113"));
                txtOriginalPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtNewPassword.Text))
            {
                SetMessage(GetMessage("E00114"));
                txtNewPassword.Focus();
                return;
            }
            if (DataValidation.IsEmpty(txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00115"));
                txtConfirmedPassword.Focus();
                return;
            }

            if (!DataValidation.IsEqual(txtNewPassword.Text, txtConfirmedPassword.Text))
            {
                SetMessage(GetMessage("E00116"));
                txtNewPassword.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator admin = new Johnny.CMS.BLL.Access.Administrator();
            string strPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOriginalPassword.Text, "MD5");

            //check old password
            if (!admin.CheckLogin(DataConvert.GetString(Session["UserName"]), strPwd))
            {
                SetMessage(GetMessage("E00117"));
                txtOriginalPassword.Focus();
                return;
            }

            Johnny.CMS.OM.Access.Administrator model = new Johnny.CMS.OM.Access.Administrator();
            model.AdminId       = DataConvert.GetInt32(Session["UserId"]);
            model.Password      = FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPassword.Text, "MD5");
            model.UpdatedTime   = System.DateTime.Now;
            model.UpdatedById   = DataConvert.GetInt32(Session["UserId"]);
            model.UpdatedByName = DataConvert.GetString(Session["UserName"]);
            admin.ResetPassword(model);
            SetMessage(GetMessage("E00118"));
        }
Пример #3
0
        protected void imgbtnLogin_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            this.lblStatus.Text = "";

            string strAdminname = StringHelper.htmlInputText(this.txtAdminName.Text);
            string strAdminPW   = StringHelper.htmlInputText(this.txtPassword.Text);

            if (strAdminname == String.Empty || strAdminPW == String.Empty)
            {
                this.lblStatus.Text = GetMessage("F00101");
                return;
            }

            if (Session["CheckCode"] == null)
            {
                Response.Redirect("login.aspx");
                return;
            }

            //check validation code
            if (Session["CheckCode"].ToString() != txtVerifyCode.Text.Trim())
            {
                this.lblStatus.Text     = GetMessage("F00102");
                this.txtVerifyCode.Text = "";
                this.txtVerifyCode.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator admin = new Johnny.CMS.BLL.Access.Administrator();
            strAdminPW = FormsAuthentication.HashPasswordForStoringInConfigFile(strAdminPW, "MD5");
            if (admin.CheckLogin(strAdminname, strAdminPW))
            {
                //update login times and login time
                admin.UpdateLoginTimes(strAdminname);
                Session["UserId"]        = admin.GetUserIdByName(strAdminname);
                Session["UserName"]      = strAdminname;
                Session["IsFirstAccess"] = "true";
                Response.Redirect("index.aspx");
            }
            else
            {
                this.txtVerifyCode.Text = "";
                this.lblStatus.Text     = GetMessage("F00103");
            }
        }
Пример #4
0
        protected void imgbtnLogin_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            this.lblStatus.Text = "";

            string strAdminname = StringHelper.htmlInputText(this.txtAdminName.Text);
            string strAdminPW = StringHelper.htmlInputText(this.txtPassword.Text);

            if (strAdminname == String.Empty || strAdminPW == String.Empty)
            {
                this.lblStatus.Text = GetMessage("F00101");                 
                return;
            }

            if (Session["CheckCode"] == null)
            {
                Response.Redirect("login.aspx");
                return;
            }

            //check validation code
            if (Session["CheckCode"].ToString() != txtVerifyCode.Text.Trim())
            {
                this.lblStatus.Text = GetMessage("F00102");
                this.txtVerifyCode.Text = "";
                this.txtVerifyCode.Focus();
                return;
            }

            Johnny.CMS.BLL.Access.Administrator admin = new Johnny.CMS.BLL.Access.Administrator();
            strAdminPW = FormsAuthentication.HashPasswordForStoringInConfigFile(strAdminPW, "MD5");
            if (admin.CheckLogin(strAdminname, strAdminPW))
            {
                //update login times and login time
                admin.UpdateLoginTimes(strAdminname);
                Session["UserId"] = admin.GetUserIdByName(strAdminname);
                Session["UserName"] = strAdminname;
                Session["IsFirstAccess"] = "true";
                Response.Redirect("index.aspx");
            }
            else
            {
                this.txtVerifyCode.Text = "";
                this.lblStatus.Text = GetMessage("F00103");
            }
        }