diff options
| author | Bobby <[email protected]> | 2022-10-10 12:33:06 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-10-10 12:33:06 -0400 |
| commit | 5749e2db42f2908ef7c62c8ab979def0251673d7 (patch) | |
| tree | f8504d766b4d5232aaa14de793a2b92bad7ca24f | |
| parent | 7886f34fe3953a963e6af16a82712147702bf7d8 (diff) | |
| download | thatcomputerscientist-5749e2db42f2908ef7c62c8ab979def0251673d7.tar.xz thatcomputerscientist-5749e2db42f2908ef7c62c8ab979def0251673d7.zip | |
Revert "Fixed Referrer on production"
This reverts commit e201c058b75cd8f3ff0125a77ba74f2f0b3dd3f7.
| -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 d0188ea6..304c8815 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 cb7b2554..fa8af0b0 100644 --- a/thatcomputerscientist/templatetags/subdomainurls.py +++ b/thatcomputerscientist/templatetags/subdomainurls.py @@ -13,14 +13,16 @@ def subdomain_url(view_name, subdomain = None, referrer = None, *args, **kwargs) return reverse(view_name, args=args, kwargs=kwargs) if referrer: - return '//{}{}{}?referrer={}'.format( + return '{}://{}{}{}?referrer={}'.format( + 'https' if settings.SECURE_SSL_REDIRECT else 'http', subdomain, settings.HOSTS[0], reverse(view_name, args=args, kwargs=kwargs), referrer ) - return '//{}{}{}'.format( + return '{}://{}{}{}'.format( + 'https' if settings.SECURE_SSL_REDIRECT else 'http', subdomain, settings.HOSTS[0], reverse(view_name, args=args, kwargs=kwargs) diff --git a/users/views.py b/users/views.py index 5a7757a4..f1a6300b 100644 --- a/users/views.py +++ b/users/views.py @@ -17,16 +17,14 @@ import django.contrib.auth.password_validation as validators from django.views.decorators.csrf import csrf_exempt def get_ref(request): - 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 + referrer = request.META.get('QUERY_STRING').split('referrer=')[1].split('?')[0] + return referrer or request.META.get('HTTP_REFERER') def home(request): - return redirect('blog:home') + 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!') @csrf_exempt # Create your views here. |
