示例#1
0
        public async Task <TokenModel> LoginAsync(LoginModel login)
        {
            AdministratorModel customer = await _administratorBusiness.GetAdministratorByEmailAsync(login.Email);

            if (customer == null)
            {
                throw new KeyNotFoundException("Usuário ou senha inválidos");
            }

            await ValidateSamePasswordAsync(login.Password, customer.Password);

            string permissions = await _permissionBusiness.GetPermissionByAdministratorIdAsync(customer.Id);

            return(await _tokenHandler.CreateJwtToken(customer, permissions));
        }