Commit 0c0eee9e authored by Jason Yeomans's avatar Jason Yeomans
Browse files

Trying more login stuff.... still no luck on user.is_authenticated

parent 4349a128
......@@ -25,6 +25,16 @@ TEMPLATE_LOADERS = (
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
......
......@@ -5,8 +5,8 @@ admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^login/$', views.login, name='login'),
url(r'^logout/$', views.logout_view, name='logout_view'),
url(r'^accounts/login/$', views.login, name='login'),
url(r'^accounts/logout/$', views.logout_view, name='logout_view'),
url(r'^buildings/$', views.buildings, name='buildings'),
url(r'^building/(?P<buildingName>[a-zA-Z]+)$', views.building, name='building'),
)
......@@ -35,11 +35,10 @@ def login(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = AuthenticationForm(data = request.POST)
# check whether it's valid:
form.is_valid()
form_data = form.clean()
user = form.get_user()
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
# the password verified for the user
if user.is_active:
......
......@@ -22,10 +22,10 @@
{% if user.is_authenticated %}
<li><a href="#">{{ user.username }}</a>
</li>
<li><a href="/logout/">Logout</a>
<li><a href="/accounts/logout/">Logout</a>
</li>
{% else %}
<li><a href="/login/">Login</a>
<li><a href="/accounts/login/">Login</a>
</li>
{% endif %}
</ul>
......
......@@ -11,13 +11,13 @@
</div>
</div>
<form class="form-signin" role="form" action="/login/" method="post">
{% csrf_token %}
<h2 class="form-signin-heading">Please sign in</h2>{{ form.errors }} {{ form.non_field_errors }} {{ form.username.errors }}
<label for="{{ form.username.id_for_label }}" class="sr-only">NetID</label>
{{ form.username }} {{ form.password.errors }}
<label for="{{ form.password.id_for_label }}" class="sr-only">Password</label>
{{ form.password }}
<form class="form-signin" role="form" action="/accounts/login/" method="post">
{% csrf_token %}
<h2 class="form-signin-heading">Please sign in</h2>
<label for="username" class="sr-only">Username</label>
<input type="text" id="inputUsername" name="username" class="form-control" placeholder="Mason NetID" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment