コード例 #1
0
ファイル: Usr.cs プロジェクト: squirlyfoxy/Battleship-Online
        internal static void Login() //Login in mysql database
        {
            do
            {
                Console.Write("Username? ");
                Dipendences.username = Console.ReadLine();
            } while (string.IsNullOrWhiteSpace(Dipendences.username) || string.IsNullOrEmpty(Dipendences.username));

            do
            {
                Console.Write("Password? ");
                Dipendences.password = Console.ReadLine();
            } while (string.IsNullOrWhiteSpace(Dipendences.password) || string.IsNullOrEmpty(Dipendences.password));

            Dipendences.password = Security.AES.CalculateMD5Hash(Dipendences.password);

            //Check if Exist on mysql
            MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM usr WHERE username = '******' AND password = '******'", conn);

            adapter.Fill(table);

            if (table.Rows.Count <= 0)
            {
                //Invalid Login
                Instruments.ErrMessage("Username or Password invalid");

                Console.WriteLine("Press Any Key To Continue...");
                Console.ReadKey();
                Console.Clear();

                Login();
            }
            else
            {
                //Valid Login
                Dipendences.logged = true;
            }

            table.Clear();

            Del(); //Delete all posizioni and mosse rows
        }