protected void SubmitBtn_Click()
 {
     CUser user = new CUser();
     List<CUser> userList = new List<CUser>();
     userList=user.GetUserById(Convert.ToInt32(Session["user_id"]));
     MD5 md5hash = MD5.Create();
     if (userList.Count > 0 )
     {
         try
         {
             bool found = false;
             foreach (CUser u in userList)
             {
                 if (u.user_password == user.GetMd5Hash(md5hash, old_password.Text))
                 {
                     user.user_id = Convert.ToInt32(Session["user_id"]);
                     user.updated_by = (string)Session["user_name"];
                     user.user_password = user.GetMd5Hash(md5hash, new_password.Text);
                     user.UpdatePassword();
                     found = true;
                     ltrlmsg.Text = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> Password Update Success</div>";
                 }
             }
             if (found == false)
             {
                 ltrlmsg.Text = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> Old Password Error</div>";
             }
         }
         catch (Exception ex)
         {
             ltrlmsg.Text = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> " + ex.Message + "</div>";
         }
     }
 }
        protected void SubmitBtn_Click()
        {
            CUser        user     = new CUser();
            List <CUser> userList = new List <CUser>();

            userList = user.GetUserById(Convert.ToInt32(Session["user_id"]));
            MD5 md5hash = MD5.Create();

            if (userList.Count > 0)
            {
                try
                {
                    bool found = false;
                    foreach (CUser u in userList)
                    {
                        if (u.user_password == user.GetMd5Hash(md5hash, old_password.Text))
                        {
                            user.user_id       = Convert.ToInt32(Session["user_id"]);
                            user.updated_by    = (string)Session["user_name"];
                            user.user_password = user.GetMd5Hash(md5hash, new_password.Text);
                            user.UpdatePassword();
                            found        = true;
                            ltrlmsg.Text = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> Password Update Success</div>";
                        }
                    }
                    if (found == false)
                    {
                        ltrlmsg.Text = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> Old Password Error</div>";
                    }
                }
                catch (Exception ex)
                {
                    ltrlmsg.Text = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button> " + ex.Message + "</div>";
                }
            }
        }
        public static string Submit(string user_name,string user_password, bool ischecked)
        {
            string strErr = "";
            TextBox txt_login_email;
            TextBox txt_login_password;
            Page page = (Page)HttpContext.Current.Handler;
            if (user_name.Trim() == "" || user_password.Trim() == "")
            {
                strErr = "<div class='alert alert-danger'><i class='fa fa-bell-o'></i>  Username/Email or Password still empty! </div>";
            }
            else
            {

                //           string str_login_email = Microsoft.Security.Application.Encoder.JavaScriptEncode(user_name);
                //           string str_login_password = Microsoft.Security.Application.Encoder.JavaScriptEncode(user_password);

                using (MD5 md5Hash = MD5.Create())
                {
                    CUser userObj = new CUser();
                    string hash = userObj.GetMd5Hash(md5Hash, user_password);
                    List<CUser> lstUser = new List<CUser>();
                    lstUser = userObj.Login(user_name, hash);
                    if (lstUser.Count() > 0)
                    {
                        Login objLogin = new Login();
                        objLogin.RegisterSession(lstUser);
                        if (ischecked == true)
                        {
                            Login objLogin2 = new Login();
                            objLogin2.RegisterCookie(lstUser);
                        }
                    }
                    else
                    {
                        strErr = "<div class='alert alert-danger'><i class='fa fa-bell-o'></i>  Username/Email and Password is wrong! </div>";
                    }
                }

            }
            return strErr;
        }
Пример #4
0
        public static string Submit(string user_name, string user_password, bool ischecked)
        {
            string  strErr = "";
            TextBox txt_login_email;
            TextBox txt_login_password;
            Page    page = (Page)HttpContext.Current.Handler;

            if (user_name.Trim() == "" || user_password.Trim() == "")
            {
                strErr = "<div class='alert alert-danger'><i class='fa fa-bell-o'></i>  Username/Email or Password still empty! </div>";
            }
            else
            {
                //           string str_login_email = Microsoft.Security.Application.Encoder.JavaScriptEncode(user_name);
                //           string str_login_password = Microsoft.Security.Application.Encoder.JavaScriptEncode(user_password);

                using (MD5 md5Hash = MD5.Create())
                {
                    CUser        userObj = new CUser();
                    string       hash    = userObj.GetMd5Hash(md5Hash, user_password);
                    List <CUser> lstUser = new List <CUser>();
                    lstUser = userObj.Login(user_name, hash);
                    if (lstUser.Count() > 0)
                    {
                        Login objLogin = new Login();
                        objLogin.RegisterSession(lstUser);
                        if (ischecked == true)
                        {
                            Login objLogin2 = new Login();
                            objLogin2.RegisterCookie(lstUser);
                        }
                    }
                    else
                    {
                        strErr = "<div class='alert alert-danger'><i class='fa fa-bell-o'></i>  Username/Email and Password is wrong! </div>";
                    }
                }
            }
            return(strErr);
        }