diff --git a/server/oauth/user_signup_login_handler.py b/server/oauth/user_signup_login_handler.py index 38f1fec1..cb29c045 100644 --- a/server/oauth/user_signup_login_handler.py +++ b/server/oauth/user_signup_login_handler.py @@ -21,9 +21,6 @@ def handle_user_and_verify_products(user_data, token): license = License.objects.get_active_license_for_user(user) - if license and not license.is_valid(): - license = None - if not license: license, error_msg = check_and_create_licenses(hep_client, user, token) diff --git a/server/users/managers.py b/server/users/managers.py index 1a99c36e..10c958d8 100644 --- a/server/users/managers.py +++ b/server/users/managers.py @@ -160,7 +160,10 @@ class LicenseManager(models.Manager): isbn=isbn, hep_created_at=activation_date) def get_active_license_for_user(self, user): - licenses = self.filter(licensee=user, expire_date__gte=timezone.now()).order_by('-expire_date') + licenses = self.filter(licensee=user, expire_date__gte=timezone.now()).order_by( + "-expire_date" + ) + licenses = [license for license in licenses if license.is_valid()] if len(licenses) == 0: return None