Skip to content

Commit

Permalink
Fixes #615: Account for BASE_PATH in static URLs and during login
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Oct 13, 2016
1 parent 579ed0a commit 49cbdc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions netbox/netbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
# 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"),
)
Expand All @@ -176,8 +176,7 @@
}

# Authentication URLs
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/{}login/'.format(BASE_PATH)

# Secrets
SECRETS_MIN_PUBKEY_SIZE = 2048
Expand Down
5 changes: 2 additions & 3 deletions netbox/users/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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())
Expand Down

0 comments on commit 49cbdc2

Please sign in to comment.