Skip to content

Commit

Permalink
Login redirects properly if user.is_authenticated()
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-bridge committed Jan 25, 2016
1 parent 4dd65f8 commit fc8e2d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tickets/templates/registration/loginform.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ <h4 class="light nnt-orange">Login</h4>
{% csrf_token %}
<div class="row">
<div class="input-field col s12">
<input name="{{ form.username.name }}" type="text" class="validate">
<input name="{{ form.username.name }}" type="text" class="validate" id="username">
<label for="{{ form.username.name }}">Username</label>
</div>
<div class="input-field col s12">
<input name="{{ form.password.name }}" type="password" class="validate">
<input name="{{ form.password.name }}" type="password" class="validate" id="password">
<label for="{{ form.password.name }}">Password</label>
</div>
<button type="submit" value="login" class="btn nnt purple waves-effect waves-dark pad-bottom">
<button type="submit" value="login" class="btn nnt purple waves-effect waves-dark pad-bottom" id="submit">
Login
</button>
<div class="input-field col s12">
Expand Down
7 changes: 4 additions & 3 deletions tickets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import json
import csv

from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.views import login
from django.contrib.auth import authenticate, logout
from django.contrib.auth.decorators import login_required

from django.views import generic
Expand All @@ -39,7 +38,9 @@ def login(request, **kwargs):
next = request.GET.get('next', '/')
return HttpResponseRedirect(request.GET.get('next', '/'))
else:
return login(request, authentication_form=forms.login_form)
from django.contrib.auth.views import login

return login(request)


def logout_view(request):
Expand Down

0 comments on commit fc8e2d7

Please sign in to comment.