Fix: login redirect to use the
next get var form url
This commit is contained in:
parent
73b4e26372
commit
a210588452
1 changed files with 4 additions and 3 deletions
|
@ -11,8 +11,8 @@ from .forms import LoginForm, SignUpForm
|
||||||
def login_view(request):
|
def login_view(request):
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
# User is already logged in, redirect them to the home page
|
# User is already logged in, redirect them to the home page
|
||||||
return redirect('/')
|
next_page = request.GET.get('next', '/')
|
||||||
|
return redirect(next_page)
|
||||||
form = LoginForm(request.POST or None)
|
form = LoginForm(request.POST or None)
|
||||||
|
|
||||||
msg = None
|
msg = None
|
||||||
|
@ -25,7 +25,8 @@ def login_view(request):
|
||||||
user = authenticate(username=username, password=password)
|
user = authenticate(username=username, password=password)
|
||||||
if user is not None:
|
if user is not None:
|
||||||
login(request, user)
|
login(request, user)
|
||||||
return redirect("/")
|
next_page = request.GET.get('next', '/')
|
||||||
|
return redirect(next_page)
|
||||||
else:
|
else:
|
||||||
msg = 'Invalid credentials'
|
msg = 'Invalid credentials'
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue