Esempio n. 1
0
        private void Login(string[] message, Socket ClientSocket)
        {
            string username = message[1];
            string password = message[2];
            string confirmation;

            if (database.IsLoggedIn(message[1]))
            {
                confirmation = "LoginF" + "," + "You are already logged in";
                ClientSocket.Send(Encoding.ASCII.GetBytes(confirmation), confirmation.Length, SocketFlags.None);
                messageBox.AppendText(username + " : Failed Login Attempt\n");
            }
            else
            {
                if (database.AuthenticateUser(username, password))
                {
                    confirmation = "LoginS" + "," + username + "," + " You Logged in Successfully";
                    database.AddLogin(username);
                    ClientSocket.Send(Encoding.ASCII.GetBytes(confirmation), confirmation.Length, SocketFlags.None);
                    messageBox.AppendText(username + " : Logged In successfully\n");
                }
                else
                {
                    confirmation = "LoginF" + "," + "Invalid Credentials";
                    ClientSocket.Send(Encoding.ASCII.GetBytes(confirmation), confirmation.Length, SocketFlags.None);
                    messageBox.AppendText("Failed login Attempt\n");
                }
            }
        }