Skip to content

Commit ca99ffd

Browse files
authored
AAP-29291: Trial: redirect Anonymous used to the login page (#1344)
If an Anonymous hits /trial, we now redirect it to the Login page. This will be enough to avoid the err 500.
1 parent 52de54e commit ca99ffd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ansible_ai_connect/users/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from django.apps import apps
1818
from django.conf import settings
19+
from django.contrib.auth.models import AnonymousUser
1920
from django.forms import Form
2021
from django.http import HttpResponseForbidden, HttpResponseRedirect
2122
from django.shortcuts import render
@@ -158,6 +159,9 @@ def get_trial_plan(self):
158159
return trial_plan
159160

160161
def dispatch(self, request, *args, **kwargs):
162+
if isinstance(request.user, AnonymousUser):
163+
return HttpResponseRedirect(reverse("login"))
164+
161165
if any(up.plan == self.get_trial_plan() for up in request.user.userplan_set.all()):
162166
return super().dispatch(request, *args, **kwargs)
163167

0 commit comments

Comments
 (0)