Exemplo n.º 1
0
        public static string ChangePassword(string sName, string sEmail, bool bySystem)
        {
            string          sResult = "";
            MySqlConnection conn    = CMain.GetConnection(ApplicationSession.DBName);
            CMember         member  = new CMember(sEmail, conn);

            if (member.IsEmpty())
            {
                sResult = "UserID/Email has not been registered. Please SignUp to register.";
            }
            else
            {
                string sNewPassword = CKeyGenerator.GetUniqueKey(8);
                bool   bln          = member.ChangePassword(conn, member.ID, sEmail, sNewPassword, bySystem);
                if (bln)
                {
                    string sSubject = "DreamWeb Reset Password";
                    string sMessage = "Hi " + sName + ", ";
                    sMessage += "<br /> <br /> Here is your temporary password: "******"<br /> Please, use this password to login.";
                    sMessage += "<br /> <br /> Thanks and Regards, <br /> <br /> <br /> DreamPosWeb Support";

                    sResult = SendEmail(sName, sEmail, sSubject, sMessage);
                }
                else
                {
                    sResult = "Fail to update password. Please try again.";
                }
            }

            return(sResult);
        }
        private string DoChangePassword(string sPswd)
        {
            string          errMsg = "";
            MySqlConnection conn   = CMain.GetConnection(ApplicationSession.DBName);
            string          sEmail = ApplicationSession.member.Email;
            CMember         member = new CMember(sEmail, conn);

            if (member.IsEmpty())
            {
                errMsg = "UserID/Email has not been registered. Please SignUp to register";
            }
            else
            {
                bool bln = member.ChangePassword(conn, member.ID, sEmail, sPswd, false);
                if (!bln)
                {
                    errMsg = "Fail to update password. Please try again.";
                }
            }
            return(errMsg);
        }