refactored login view to be more standard
This commit is contained in:
parent
d48cf18566
commit
aeaaa1df2b
|
@ -14,9 +14,7 @@ def index(request):
|
||||||
"""
|
"""
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
return redirect('homepage:index')
|
return redirect('homepage:index')
|
||||||
if request.method == "GET":
|
if request.method == 'POST':
|
||||||
form = LoginForm()
|
|
||||||
return render(request, 'login/index.html', {'form': form})
|
|
||||||
form = LoginForm(request.POST)
|
form = LoginForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
user = authenticate(
|
user = authenticate(
|
||||||
|
@ -28,4 +26,6 @@ def index(request):
|
||||||
messages.success(request, "Logged in")
|
messages.success(request, "Logged in")
|
||||||
return redirect('homepage:index')
|
return redirect('homepage:index')
|
||||||
messages.error(request, "Invalid credentials")
|
messages.error(request, "Invalid credentials")
|
||||||
|
else:
|
||||||
|
form = LoginForm()
|
||||||
return render(request, 'login/index.html', {'form': form})
|
return render(request, 'login/index.html', {'form': form})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user