1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

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

This commit is contained in:
Jeremy Stretch
2016-10-13 16:27:09 -04:00
parent 579ed0a985
commit 49cbdc22da
2 changed files with 4 additions and 6 deletions

View File

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

View File

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