diff options
| author | Bobby <[email protected]> | 2022-10-10 12:09:26 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-10-10 12:09:26 -0400 |
| commit | e201c058b75cd8f3ff0125a77ba74f2f0b3dd3f7 (patch) | |
| tree | 785dc58b5d58f72d5a503b9b928003422ef46834 | |
| parent | 69cba5af4a819ef732e3bbb7918bacf3c020808f (diff) | |
| download | thatcomputerscientist-e201c058b75cd8f3ff0125a77ba74f2f0b3dd3f7.tar.xz thatcomputerscientist-e201c058b75cd8f3ff0125a77ba74f2f0b3dd3f7.zip | |
Fixed Referrer on production
| -rw-r--r-- | thatcomputerscientist/settings.py | 2 | ||||
| -rw-r--r-- | thatcomputerscientist/templatetags/subdomainurls.py | 6 | ||||
| -rw-r--r-- | users/views.py | 14 |
3 files changed, 11 insertions, 11 deletions
diff --git a/thatcomputerscientist/settings.py b/thatcomputerscientist/settings.py index 304c8815..d0188ea6 100644 --- a/thatcomputerscientist/settings.py +++ b/thatcomputerscientist/settings.py @@ -31,7 +31,7 @@ SECRET_KEY = os.getenv('AUTHORIZATION_STRING') DEBUG = os.getenv('ENVIRONMENT') == 'development' or False ALLOWED_HOSTS = ["*"] -HOSTS = [".vcap.me"] if os.getenv('ENVIRONMENT') == 'development' else ".thatcomputerscientist.com" +HOSTS = [".vcap.me"] if os.getenv('ENVIRONMENT') == 'development' else [".thatcomputerscientist.com"] CSRF_TRUSTED_ORIGINS = ['http://*.localhost', 'https://*.thatcomputerscientist.com', 'https://*.thatcomputerscientist.fly.dev/', 'http://*.vcap.me'] SESSION_COOKIE_DOMAIN = ".vcap.me" if os.getenv('ENVIRONMENT') == 'development' else ".thatcomputerscientist.com" DOMAIN_NAME = "vcap.me" if os.getenv('ENVIRONMENT') == 'development' else "thatcomputerscientist.com" diff --git a/thatcomputerscientist/templatetags/subdomainurls.py b/thatcomputerscientist/templatetags/subdomainurls.py index fa8af0b0..cb7b2554 100644 --- a/thatcomputerscientist/templatetags/subdomainurls.py +++ b/thatcomputerscientist/templatetags/subdomainurls.py @@ -13,16 +13,14 @@ def subdomain_url(view_name, subdomain = None, referrer = None, *args, **kwargs) return reverse(view_name, args=args, kwargs=kwargs) if referrer: - return '{}://{}{}{}?referrer={}'.format( - 'https' if settings.SECURE_SSL_REDIRECT else 'http', + return '//{}{}{}?referrer={}'.format( subdomain, settings.HOSTS[0], reverse(view_name, args=args, kwargs=kwargs), referrer ) - return '{}://{}{}{}'.format( - 'https' if settings.SECURE_SSL_REDIRECT else 'http', + return '//{}{}{}'.format( subdomain, settings.HOSTS[0], reverse(view_name, args=args, kwargs=kwargs) diff --git a/users/views.py b/users/views.py index f1a6300b..5a7757a4 100644 --- a/users/views.py +++ b/users/views.py @@ -17,14 +17,16 @@ import django.contrib.auth.password_validation as validators from django.views.decorators.csrf import csrf_exempt def get_ref(request): - referrer = request.META.get('QUERY_STRING').split('referrer=')[1].split('?')[0] - return referrer or request.META.get('HTTP_REFERER') + try: + referrer = request.META.get('QUERY_STRING').split('referrer=')[1] + except: + referrer = request.META.get('HTTP_REFERER') + if '?' in referrer: + referrer = referrer.split('?')[0] + return referrer def home(request): - if request.user.is_authenticated: - return HttpResponse('Hello, {}! You are logged in!'.format(request.user)) - else: - return HttpResponse('Hello, World! You are not logged in!') + return redirect('blog:home') @csrf_exempt # Create your views here. |
