public IActionResult Post([FromBody] comum_dto.externo.AutenticacaoRequest request)
        {
            ConfiguraEmpresa(request);

            var autenticacao = new integracao_grpc.AutenticacaoExterna(request);

            return(IntegrarGRPC <comum_dto.externo.AutenticacaoResponse>(autenticacao));
        }
 public proto.AutenticarRequest Request(dto.externo.AutenticacaoRequest autenticacaoRequest)
 {
     return(new proto.AutenticarRequest
     {
         EmpresaId = autenticacaoRequest.EmpresaId.ToString(),
         Email = autenticacaoRequest.Email ?? string.Empty,
         Senha = autenticacaoRequest.Senha ?? string.Empty,
         ParceiroId = autenticacaoRequest.ParceiroId ?? string.Empty
     });
 }
Beispiel #3
0
        public ResponseEnvelope <comum_dto.externo.AutenticacaoResponse> Autenticar(comum_dto.externo.AutenticacaoRequest request)
        {
            var response = new ResponseEnvelope <comum_dto.externo.AutenticacaoResponse>();

            try
            {
                firebase.Autenticar(request.Email, request.Senha);

                var userResponse = consultaService.Obter(
                    new comum_dto.filtros.UsuarioFiltro
                {
                    EmpresaId = request.EmpresaId,
                    Email     = request.Email
                });

                response.HttpStatusCode = userResponse.HttpStatusCode;

                if (userResponse.Success)
                {
                    var token = GerarToken(userResponse.Item.Id);

                    response.Item = new comum_dto.externo.AutenticacaoResponse
                    {
                        Token   = token,
                        Nome    = userResponse.Item.Nome,
                        Apelido = userResponse.Item.Apelido
                    };
                }
            }
            catch (FirebaseAuthException fex)
            {
                var retornoNotFound = new List <AuthErrorReason>
                {
                    AuthErrorReason.UnknownEmailAddress,
                    AuthErrorReason.UserNotFound,
                };

                response.HttpStatusCode = System.Net.HttpStatusCode.BadRequest;

                response.Error.Messages.Add(fex.Reason.ToString());

                if (retornoNotFound.Contains(fex.Reason))
                {
                    response.HttpStatusCode = System.Net.HttpStatusCode.NotFound;
                }
            }
            catch (Exception ex)
            {
                // ## TODO log
                response.HttpStatusCode = System.Net.HttpStatusCode.InternalServerError;
                response.Error.Messages.Add(ex.Message);
            }

            return(response);
        }
        public adduohelper.ResponseEnvelope <dto.externo.AutenticacaoResponse> Autenticar(dto.externo.AutenticacaoRequest autenticacaoRequest)
        {
            var request = autenticarParser.Request(autenticacaoRequest);

            var autenticacaoResponse = grpcService.Autenticar(request);

            var response = autenticarParser.Response(autenticacaoResponse);

            return(response);
        }
Beispiel #5
0
 public AutenticacaoExterna(comum_dto.externo.AutenticacaoRequest request)
 {
     this.request = request;
 }