internal AuthenticationResult Authenticate(PlayerHandle sender, Command command)
            {
                if (command.Arguments.Count() < this.ArgumentIndex)
                {
                    return(AuthenticationResult.NotAuthenticated);
                }

                if (ChatActionsAuthenticator.GhostNames.Contains(command.Arguments.ElementAt(this.ArgumentIndex)))
                {
                    return(AuthenticationResult.Ok);
                }

                var matchingArgument = CharacterService.StripCharacterName(command.Arguments.ElementAt(this.ArgumentIndex));

                if (!matchingArgument.Equals(sender.Name))
                {
                    return(AuthenticationResult.NotAuthenticated);
                }

                return(AuthenticationResult.Ok);
            }
 public void Inject()
 {
     this.db = DI.Get <Database>();
     this.characterService = DI.Get <CharacterService>();
     this.loginService     = DI.Get <LoginService>();
 }
        private AuthenticationResult authenticateCommand(PlayerHandle sender, Command command)
        {
#if !DEBUG
            if (sender.AdminOptions.HasFlag(AdminFlags.DisabledAuthenticator))
            {
                return(AuthenticationResult.Ok);
            }
#endif

            switch (command.Name)
            {
            case "useSexPose":
                if (this.checkIfPoseIsForbiddenInLobby(sender, command))
                {
                    return(AuthenticationResult.SexDisabledInRoom);
                }

                var agreement = this.findPoseAgreement(sender.Name);
                if (agreement == null)
                {
                    return(AuthenticationResult.NotAuthenticated);
                }

                foreach (string participantRaw in command.Arguments.Skip(3).Take(3))
                {
                    if (participantRaw.Count() == 0)
                    {
                        continue;
                    }

                    var participant = CharacterService.StripCharacterName(participantRaw);

                    string[] participantArguments = participant.Split('=');
                    if (participantArguments.Count() != 2)
                    {
                        return(AuthenticationResult.NotAuthenticated);
                    }

                    string participantName = participantArguments.First();
                    if (!agreement.Contains(participantName))
                    {
                        return(AuthenticationResult.NotAuthenticated);
                    }
                }

                return(AuthenticationResult.Ok);

            case "stopSexPS":
                foreach (string participantRaw in command.Arguments.Skip(1))
                {
                    var participant = CharacterService.StripCharacterName(participantRaw);
                    if (participant.Equals(sender.Name))
                    {
                        return(AuthenticationResult.Ok);
                    }
                }

                return(AuthenticationResult.NotAuthenticated);

            case "askForPose":
                if (this.checkIfPoseIsForbiddenInLobby(sender, command))
                {
                    return(AuthenticationResult.SexDisabledInRoom);
                }
                else
                {
                    return(this.authenticateByTemplate(sender, command));
                }

            default:
                return(this.authenticateByTemplate(sender, command));
            }
        }