예제 #1
0
 public ServiceUsuarioTests(ITestOutputHelper testOutputHelper)
 {
     _output = testOutputHelper;
     
     this._repositoryUsuario = new RepositoryUsuario( new Infra.Persistence.EF.YouLearnContext());
     this._serviceUsuario = new ServiceUsuario(_repositoryUsuario);
 }
예제 #2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            try
            {
                IServiceUsuario serviceUsuario = _container.Resolve <IServiceUsuario>();
                var             request        = new UsuarioLoginRequest();
                request.Email = context.UserName;
                request.Senha = context.Password;
                UsuarioLoginResponse response = serviceUsuario.Autenticar(request);

                if ((serviceUsuario.IsInvalid()) || (response == null))
                {
                    context.SetError("invalid_grant", "Usuário não encontrado.");
                    serviceUsuario.ClearNotifications();
                    return;
                }

                var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                identity.AddClaim(new Claim(ClaimTypes.Name, response.Nome));
                identity.AddClaim(new Claim(ClaimTypes.Role, response.Perfil));

                var roles = new List <string>();
                roles.Add(response.Perfil);

                var principal = new GenericPrincipal(identity, roles.ToArray());
                Thread.CurrentPrincipal = principal;
                context.Validated(identity);
            }
            catch (Exception ex)
            {
                context.SetError("invalid_grant", ex.Message);
                return;
            }
        }
예제 #3
0
 public HomeController(IServiceUsuario serviceUser, IServiceApartado serviceApartado, IServiceSesion serviceSesion, IServiceFoto serviceFoto)
 {
     _serviceUser     = serviceUser;
     _serviceApartado = serviceApartado;
     _serviceSesion   = serviceSesion;
     _serviceFoto     = serviceFoto;
 }
예제 #4
0
 public ServiceCliente(IRepositoryCliente repositoryCliente, IServiceUsuario serviceUsuario, IServiceIdentidade serviceIdentidade) :
     base(repositoryCliente)
 {
     _repositoryCliente = repositoryCliente;
     _serviceUsuario    = serviceUsuario;
     _serviceIdentidade = serviceIdentidade;
 }
 /// <summary>
 /// Construtor do usuário.
 /// </summary>
 /// <param name="unitOfWork">O método responsável pelo commit.</param>
 /// <param name="serviceUsuario">O serviço de usuário.</param>
 /// <param name="accessManager">Método responsável por gerar o token</param>
 /// <param name="authenticatedUser">Obtém o usuário autenticado</param>
 public UsuarioController(IUnitOfWork unitOfWork, IServiceUsuario serviceUsuario, IServiceImagem serviceImagem, AccessManager accessManager, AuthenticatedUser authenticatedUser, IHostingEnvironment hostingEnvironment) : base(unitOfWork)
 {
     _serviceUsuario     = serviceUsuario;
     _serviceImagem      = serviceImagem;
     _accessManager      = accessManager;
     _authenticatedUser  = authenticatedUser;
     _hostingEnvironment = hostingEnvironment;
 }
예제 #6
0
 public HomeController(
     IServiceCategoriaEvento serviceCategoriaEvento,
     IServiceContato serviceContato,
     IServiceEvento serviceEvento,
     IServiceUsuario serviceUsuario)
 {
     _serviceCategoriaEvento = serviceCategoriaEvento;
     _serviceContato         = serviceContato;
     _serviceEvento          = serviceEvento;
     _serviceUsuario         = serviceUsuario;
 }
예제 #7
0
        public ManutencaoController(
            IServiceContato serviceContato,
            IServiceCategoriaEvento serviceCategoriaEvento,
            IServiceUsuario serviceUsuario
            )

        {
            _serviceContato         = serviceContato;
            _serviceCategoriaEvento = serviceCategoriaEvento;
            _serviceUsuario         = serviceUsuario;
        }
예제 #8
0
        private void ConfigurarOAuth(IAppBuilder app, IServiceUsuario serviceUsuario)
        {
            var oAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp         = true,
                TokenEndpointPath         = new PathString("/api/v1/usuario/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(30),
                Provider = new SimpleAuthorizationServerProvider(serviceUsuario)
            };

            app.UseOAuthAuthorizationServer(oAuthServerOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
예제 #9
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            try
            {
                IServiceUsuario serviceUsuario = _container.Resolve <IServiceUsuario>();


                AutenticarUsuarioRequest request = new AutenticarUsuarioRequest();
                request.Email = context.UserName;
                request.Senha = context.Password;

                AutenticarUsuarioResponse response = serviceUsuario.AutenticarUsuario(request);



                if (serviceUsuario.IsInvalid())
                {
                    if (response == null)
                    {
                        context.SetError("invalid_grant", "Preencha um e-mail válido e uma senha com pelo menos 6 caracteres.");
                        return;
                    }
                }

                serviceUsuario.ClearNotifications();

                if (response == null)
                {
                    context.SetError("invalid_grant", "Usuario não encontrado!");
                    return;
                }

                var identity = new ClaimsIdentity(context.Options.AuthenticationType);

                //Definindo as Claims
                identity.AddClaim(new Claim("Usuario", 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);
                return;
            }
        }
예제 #10
0
 /// <summary>
 /// Construtor da classe
 /// </summary>
 /// <param name="pServiceNutricionista">Serviços referênte ao nutricionista</param>
 /// <param name="pServiceUsuario">Serviço de usuário</param>
 /// <param name="pServiceEndereco">Serviço para endereço</param>
 public NutricionistaController(IServiceNutricionista pServiceNutricionista, IServiceUsuario pServiceUsuario, IServiceEndereco pServiceEndereco)
 {
     _ServiceNutricionista = pServiceNutricionista;
     _ServiceUsuario       = pServiceUsuario;
     _ServiceEndereco      = pServiceEndereco;
 }
예제 #11
0
 public LoginController(IServiceUsuario serviceUser)
 {
     _serviceUsuario = serviceUser;
 }
예제 #12
0
 public SimpleAuthorizationServerProvider(IServiceUsuario serviceUsuario)
 {
     _serviceUsuario = serviceUsuario;
 }
 public AutenticacaoController(IServiceUsuario service) => _service = service;
예제 #14
0
 public ApplicationServiceUsuario(IServiceUsuario serviceUsuario, IMapper mapper)
 {
     _serviceUsuario = serviceUsuario;
     _mapper         = mapper;
 }
예제 #15
0
 public AuthController(IServiceUsuario service, IUnitOfWork uof)
 {
     _service = service;
     _uof     = uof;
 }
예제 #16
0
 public UsuarioController(IUnitOfWork unitOfWork, IServiceUsuario serviceUsuario) : base(unitOfWork)
 {
     _serviceUsuario = serviceUsuario;
 }
예제 #17
0
 public UsuarioController(IServiceUsuario service)
 {
     _service = service;
 }
예제 #18
0
 public CanalController(IServiceUsuario serviceUsuario, IUnitOfWork unitOfWork) : base(unitOfWork)
 {
     _serviceUsuario = serviceUsuario;
 }
 /// <summary>
 /// Construtor
 /// </summary>
 /// <param name="pIServicePaciente">Serviço de paciente</param>
 /// <param name="pServiceUsuario">Serviço de usuário</param>
 public PacienteController(IServicePaciente pIServicePaciente, IServiceUsuario pServiceUsuario)
 {
     _ServicePaciente = pIServicePaciente;
     _ServiceUsuario  = pServiceUsuario;
 }
예제 #20
0
 public UsuarioController(IServiceUsuario service, IUnityOfWork unityOfWork) : base(unityOfWork)
 {
     _service = service;
 }
예제 #21
0
 public ApplicationServiceUsuario(IServiceUsuario service)
 {
     _service = service;
 }
예제 #22
0
 /// <summary>
 /// Construtor do controller.
 /// </summary>
 public UsuarioController(IServiceUsuario serviceUsuario, IHttpContextAccessor httpContextAccessor, IUnitOfWork unitOfWork) : base(unitOfWork)
 {
     _serviceUsuario      = serviceUsuario;
     _httpContextAccessor = httpContextAccessor;
 }
예제 #23
0
 public AuthController(IServiceUsuario service)
 {
     this._service = service;
 }
예제 #24
0
 /// <summary>
 /// Construtor da classe
 /// </summary>
 /// <param name="pServiceUsuario">Serviço de usuário</param>
 public LoginController(IServiceUsuario pServiceUsuario)
 {
     _ServiceUsuario = pServiceUsuario;
 }
 /// <summary>
 /// Construtor
 /// </summary>
 /// <param name="pPacienteRepository">Interface que faz os comandos com o banco de dados para paciente</param>
 public ServicePaciente(IPacienteRepository pPacienteRepository, IServiceUsuario pServiceUsuario)
 {
     _PacienteRepository = pPacienteRepository;
     _ServiceUsuario     = pServiceUsuario;
 }
예제 #26
0
 //Constructor
 public UsuariosController(IServiceUsuario service)
 {
     _respuesta      = new Respuesta.RespuestaGenerica <DtoUsuario>();
     _respuestaLogin = new Respuesta.RespuestaGenerica <DtoLoginResponse>();
     _service        = service;
 }
예제 #27
0
 public ApplicationServiceUsuario(IServiceUsuario ServiceUsuario, IMapperUsuario MapperUsuario)
 {
     _serviceUsuario = ServiceUsuario;
     _mapperUsuario  = MapperUsuario;
 }
예제 #28
0
 public UsuarioController(IServiceUsuario repository, IMapper mapper)
     : base(repository, mapper)
 {
 }
예제 #29
0
 public AppUsuario(IUsuario IUsuario, IServiceUsuario IServiceUsuario)
 {
     _IUsuario        = IUsuario;
     _IServiceUsuario = IServiceUsuario;
 }
 public AppServiceUsuario(IServiceUsuario _serviceUsuario)
 {
     serviceUsuario = _serviceUsuario;
 }