Example #1
0
        public async Task <ClienteViewModel> AuthenticateCliente(string userName, string password)
        {
            Cliente clienteFromDomain = await _clienteService.Authenticate(userName, password);

            ///Valida se autenticação funcionou e gera notificação
            if (clienteFromDomain == null)
            {
                return(null);
            }

            ClienteViewModel cliente = _mapper.Map <ClienteViewModel>(clienteFromDomain);

            cliente.Token = _tokenService.GerarTokenCliente(clienteFromDomain);

            foreach (var service in _serviceProvider.GetServices <IClienteAoLogar>())
            {
                service.hookClienteAoLogar(clienteFromDomain);
            }

            return(cliente.GetWithoutPassWord);
        }