Exemple #1
0
        public async Task <object> LoginFornecedorAsync(
            [FromServices] SigningConfigurations signingConfigurations,
            [FromServices] TokenConfigurations tokenConfigurations,
            [FromBody] FornecedorRequestDto requisicaoLogin)
        {
            try
            {
                var fornecedor = await _fornecedorBusiness.Get(requisicaoLogin);

                if (fornecedor != null)
                {
                    var result = await _tokenBusiness.LoginFornecedor(fornecedor, signingConfigurations, tokenConfigurations);

                    return(Ok(result));
                }
                else
                {
                    return(StatusCode(403, "Login inválido"));
                }
            }
            catch (Exception ex)
            {
                LogarErro(ex);
                return(StatusCode(500, "Internal server error"));
            }
        }
Exemple #2
0
        public async Task <Fornecedor> Get(FornecedorRequestDto requisicaoLogin)
        {
            var pin        = Convert.ToBase64String((Encoding.UTF8.GetBytes(requisicaoLogin.Senha)));
            var fornecedor = await Task.Run(() => _fornecedorRepository.Get(x => x.Usuario == requisicaoLogin.Usuario && x.Senha == pin));

            return(fornecedor);
        }