Ejemplo n.º 1
0
        public void ProcessAuthentication(Connection connection, LCAuthentication authentication)
        {
            //Check the salt
            if (!validateSalt(authentication.Salt))
            {
                //Probably a custom made connection, drop it and quit authentication
                connection.Socket.Disconnect(false);
                Console.WriteLine(authentication.Username + " failed authentication with reason: WRONG SALT");
                return;
            }

            //Prepare the response
            LCAuthenticationResponse response = new LCAuthenticationResponse();

            //Check the username
            if (!checkUsername(authentication.Username))
            {
                //Username is not existing in the database, send this result to the user and quit authentication
                response.Result = AuthenticationResult.BAD_USERNAME;
                connection.Send(response);
                Console.WriteLine(authentication.Username + " failed authentication with reason: BAD USERNAME");
                return;
            }

            //Check the username with the password
            if (!checkPassword(authentication.Username, authentication.Password))
            {
                //Password is not correct for this username, send this result to the user and quit authentication
                response.Result = AuthenticationResult.BAD_PASSWORD;
                connection.Send(response);
                Console.WriteLine(authentication.Username + " failed authentication with reason: BAD PASSWORD");
                return;
            }

            //Authentication succeeded
            response.Result = AuthenticationResult.SUCCESS;
            connection.Send(response);
            Console.WriteLine(authentication.Username + " successfully authenticated");

            //Send state switch
            LCStateSwitch stateSwitch = new LCStateSwitch {
                GameState = GameState.CHARACTER_SELECTION
            };

            connection.Send(stateSwitch);
            Console.WriteLine("Sent game state switch to " + stateSwitch.GameState + " - User: "******"Sent character list");
        }
Ejemplo n.º 2
0
        private void handleAuthentication(Connection connection, IPacket packet)
        {
            LCAuthentication authentication = (LCAuthentication)packet;

            AuthenticationService.ProcessAuthentication(connection, authentication);
        }