Browse Source

Fixes #615: Account for BASE_PATH in static URLs and during login

Jeremy Stretch 8 years ago
parent
commit
49cbdc22da
2 changed files with 4 additions and 6 deletions
  1. 2 3
      netbox/netbox/settings.py
  2. 2 3
      netbox/users/views.py

+ 2 - 3
netbox/netbox/settings.py

@@ -162,7 +162,7 @@ USE_TZ = True
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/1.8/howto/static-files/
 STATIC_ROOT = BASE_DIR + '/static/'
-STATIC_URL = '/static/'
+STATIC_URL = '/{}static/'.format(BASE_PATH)
 STATICFILES_DIRS = (
     os.path.join(BASE_DIR, "project-static"),
 )
@@ -176,8 +176,7 @@ MESSAGE_TAGS = {
 }
 
 # Authentication URLs
-LOGIN_URL = '/login/'
-LOGIN_REDIRECT_URL = '/'
+LOGIN_URL = '/{}login/'.format(BASE_PATH)
 
 # Secrets
 SECRETS_MIN_PUBKEY_SIZE = 2048

+ 2 - 3
netbox/users/views.py

@@ -1,10 +1,9 @@
-from django.conf import settings
 from django.contrib import messages
 from django.contrib.auth import login as auth_login, logout as auth_logout, update_session_auth_hash
 from django.contrib.auth.decorators import login_required
 from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect
-from django.shortcuts import redirect, render, resolve_url
+from django.shortcuts import redirect, render
 from django.utils.http import is_safe_url
 
 from secrets.forms import UserKeyForm
@@ -26,7 +25,7 @@ def login(request):
             # Determine where to direct user after successful login
             redirect_to = request.POST.get('next', '')
             if not is_safe_url(url=redirect_to, host=request.get_host()):
-                redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)
+                redirect_to = reverse('home')
 
             # Authenticate user
             auth_login(request, form.get_user())