Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
0c0eee9e
Commit
0c0eee9e
authored
Nov 20, 2014
by
Jason Yeomans
Browse files
Trying more login stuff.... still no luck on user.is_authenticated
parent
4349a128
Changes
5
Hide whitespace changes
Inline
Side-by-side
roomlist/django_project/settings.py
View file @
0c0eee9e
...
...
@@ -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/
...
...
roomlist/roomlist/urls.py
View file @
0c0eee9e
...
...
@@ -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'
),
)
roomlist/roomlist/views.py
View file @
0c0eee9e
...
...
@@ -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
:
...
...
roomlist/templates/layouts/navbar.html
View file @
0c0eee9e
...
...
@@ -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>
...
...
roomlist/templates/login.html
View file @
0c0eee9e
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment