public IndicatorLoginDTO Login(string cpf, string password) { IndicatorUtil Util = new IndicatorService(); if (Util.StringIsNull(cpf)) { throw new BadRequestException("CPF deve ser preenchido"); } if (Util.StringIsNull(password)) { throw new BadRequestException("SENHA deve ser preenchida"); } if (_cpfValidate.ValidaCPF(cpf) == false) { throw new BadRequestException($"CPF inválido: {cpf}"); } Indicator indicator = _repository.GetIndicatorLogin(cpf, password); if (Util.ObjectIsNull(indicator)) { throw new NotFoundException("CPF ou SENHA inválidos"); } switch (indicator.Status) { case Enums.IndicatorStatus.INACTIVE: throw new BadRequestException("Este usuário está inativo :c"); case Enums.IndicatorStatus.BLOCKED: throw new BadRequestException("Este usuário está bloqueado :c"); } if (indicator.IsConfirmed.Equals(AccountConfirm.NOT_CONFIRMED)) { throw new BadRequestException("NOT_CONFIRMED"); } // Gera o Token para indicador var token = TokenService.GenerateTokenIndicator(indicator); IndicatorLoginDTO indicatorLogged = new IndicatorLoginDTO(); indicatorLogged.Id = indicator.Id; indicatorLogged.CPF = indicator.CPF; indicatorLogged.Email = indicator.Email; indicatorLogged.Name = indicator.Name; indicatorLogged.Status = indicator.Status; indicatorLogged.PaymentAccounts = indicator.PaymentAccounts; indicatorLogged.Token = token; return(indicatorLogged); }