예제 #1
0
        public async Task <IActionResult> LoginFuncionario([FromBody] LoginDto login)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            var result = await _contaService.AutenticarFuncionario(login.Email, login.Senha);

            if (!OperacaoValida())
            {
                return(CustomResponse());
            }

            if (result.PrimeiroAcesso)
            {
                return(CustomResponse(new { Id = result.Value.Usuario.Id, PrimeiroAcesso = result.PrimeiroAcesso }));
            }

            return(CustomResponse(await _authService.ObterResponseToken(new UsuarioResponseDto(result.Value.Usuario.Id, result.Value.Email.Endereco, (int)result.Value.Cargo.Categoria))));
        }