Beispiel #1
0
        public static bool LoginAccount(string sAccount, string sPassword)
        {
            MySqlConnection conexion = ObtenerConexion();
            MySqlCommand    cmd      = new MySqlCommand();
            string          sPwdMD5  = LibraryController.GenerateMySQL5PasswordHash(sPassword);

            cmd.Connection = conexion;
            try
            {
                cmd.CommandText = "SELECT id FROM account.account WHERE login = '******' and password = '******'";
                int valor = Convert.ToInt32(cmd.ExecuteScalar());
                if (valor >= 1)
                {
                    conexion.Close();
                    return(true);
                }
                else
                {
                    conexion.Close();
                    return(false);
                };
            }
            catch (Exception)
            {
                conexion.Close();
                return(false);
            }
        }
Beispiel #2
0
        public static bool ChangePasswordByPasswordAndAccount(string sAccount, string sPassword, string sNewPassword)
        {
            int             valor;
            string          sPwdMD5  = LibraryController.GenerateMySQL5PasswordHash(sPassword);
            string          sNewPwd  = LibraryController.GenerateMySQL5PasswordHash(sNewPassword);
            MySqlConnection conexion = ObtenerConexion();
            MySqlCommand    cmd      = new MySqlCommand();

            cmd.Connection = conexion;

            try
            {
                cmd.CommandText = "UPDATE account.account SET password= '******' WHERE login = '******' and password = '******' ";
                valor           = Convert.ToInt32(cmd.ExecuteNonQuery());
                if (valor >= 1)
                {
                    conexion.Close();
                    return(true);
                }
                else
                {
                    conexion.Close();
                    return(false);
                }
            }
            catch (Exception)
            {
                conexion.Close();
                return(false);
            }
        }
Beispiel #3
0
        public static int RegisterAccount(string sAccount, string sPassword, string sEmail, string sRemoveCode)
        {
            MySqlConnection conexion = ObtenerConexion();
            MySqlCommand    cmd      = new MySqlCommand();

            cmd.Connection = conexion;
            int      retorno          = 0;
            DateTime dateTimeVariable = DateTime.Now;
            string   sGetDateTime     = dateTimeVariable.ToString("yyyy-MM-dd H:mm:ss");
            string   sPwdMD5          = LibraryController.GenerateMySQL5PasswordHash(sPassword);

            cmd.CommandText = "SELECT * FROM account.account WHERE login = '******'";
            retorno         = Convert.ToInt32(cmd.ExecuteScalar());
            if (retorno >= 1)
            {
                return(retorno = 0);
            }
            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO account (login, password, social_id, email) values ('{0}','{1}','{2}', '{3}')",
                                                                  sAccount, sPwdMD5, sRemoveCode, sEmail), conexion);

            retorno = comando.ExecuteNonQuery();
            conexion.Close();
            return(retorno);
        }