예제 #1
0
        public void LocalLogin()
        {
            bool loggingIn = true;

            while (loggingIn)
            {
                Console.Write("\nUsername: "******"Password: "******"";
                ConsoleKeyInfo key;

                do
                {
                    key = Console.ReadKey(true);

                    if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
                    {
                        pass += key.KeyChar;
                    }
                }while (key.Key != ConsoleKey.Enter);
                Console.WriteLine();

                if (username != "" && pass != "")   // Cannot be empty
                {
                    if (SQLMethod.SQLLogin(username, pass))
                    {
                        loggingIn = false;
                        methods.FinalPage(username);
                    }
                    else
                    {
                        Console.WriteLine("Wrong username or password. Press enter to try again or ESC to go back to login page");
                        key = Console.ReadKey();

                        // Remove Esc character
                        Console.SetCursorPosition(0, Console.CursorTop);
                        Console.WriteLine(" ");

                        loggingIn = key.Key != ConsoleKey.Escape;
                    }
                }
                else
                {
                    Console.WriteLine("Username or password can't be empty");
                }
            }
        } // LocalLogin end
예제 #2
0
        private void WsServer_NewMessageReceived(WebSocketSession session, string value)
        {
            Methods    method    = new Methods();
            SQLMethods SQLMethod = new SQLMethods();

            string[] splittet = value.Split(',');
            if (SQLMethod.SQLLogin(splittet[0], splittet[1]))
            {
                session.Send("Luk");
                waiting = false;
                method.FinalPage(splittet[0]);
            }
            else
            {
            }
        }