Exemplo n.º 1
0
 public ServiceBuildResult(IAudioService audioService, ICommunicator communicator,
                           IServicePlayer servicePlayer, ReadWriteAudioServiceData data)
 {
     AudioService  = audioService;
     Communicator  = communicator;
     ServicePlayer = servicePlayer;
     Data          = data;
 }
Exemplo n.º 2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            try
            {
                IServicePlayer servicePlayer = _container.Resolve <IServicePlayer>();

                AuthenticatePlayerRequest request = new AuthenticatePlayerRequest();
                request.Email    = context.UserName;
                request.Password = context.Password;
                AuthenticatePlayerResponse response = servicePlayer.AuthenticatePlayer(request);

                if (servicePlayer.IsInvalid())
                {
                    if (response == null)
                    {
                        context.SetError("invalid_grant", "Preencha um e-mail válido e uma senha com pelo menos 6 caracteres.");
                        return;
                    }
                }
                servicePlayer.ClearNotifications();
                if (response == null)
                {
                    context.SetError("invalid_grant", "Jogador não encontrado!");
                    return;
                }
                var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                //Definindo as Claims
                identity.AddClaim(new Claim("Player", JsonConvert.SerializeObject(response)));
                var principal = new GenericPrincipal(identity, new string[] { });
                Thread.CurrentPrincipal = principal;
                context.Validated(identity);
            }
            catch (Exception ex)
            {
                context.SetError("invalid_grant", ex.Message);
            }
        }
Exemplo n.º 3
0
 public PlayerController(IServicePlayer servicePlayer)
 {
     _servicePlayer = servicePlayer;
 }