Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
fdbcbec0
Commit
fdbcbec0
authored
Jul 08, 2016
by
lhark
Browse files
Add login system
parent
47f930b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
re2o/settings.py
View file @
fdbcbec0
...
...
@@ -29,6 +29,8 @@ PASSWORD_HASHERS = (
)
AUTH_USER_MODEL
=
'users.User'
LOGIN_URL
=
'/login'
LOGIN_REDIRECT_URL
=
'/'
# Application definition
...
...
@@ -80,6 +82,10 @@ TEMPLATES = [
},
]
TEMPLATE_CONTEXT_PROCESSORS
=
(
'django.core.context_processors.request'
,
)
WSGI_APPLICATION
=
're2o.wsgi.application'
...
...
@@ -119,5 +125,3 @@ STATICFILES_DIRS = (
STATIC_URL
=
'/static/'
STATIC_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'static_files'
)
LOGIN_URL
=
'/admin/'
re2o/urls.py
View file @
fdbcbec0
...
...
@@ -14,11 +14,14 @@ Including another URLconf
"""
from
django.conf.urls
import
include
,
url
from
django.contrib
import
admin
from
django.contrib.auth
import
views
as
auth_views
from
logs.views
import
index
urlpatterns
=
[
url
(
r
'^$'
,
index
),
url
(
'^logout/'
,
auth_views
.
logout
,
{
'next_page'
:
'/'
}),
url
(
'^'
,
include
(
'django.contrib.auth.urls'
)),
url
(
r
'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r
'^users/'
,
include
(
'users.urls'
,
namespace
=
'users'
)),
url
(
r
'^search/'
,
include
(
'search.urls'
,
namespace
=
'search'
)),
...
...
templates/base.html
View file @
fdbcbec0
...
...
@@ -46,7 +46,17 @@
</form>
</div>
<ul
class=
"nav navbar-nav navbar-right"
>
<li><a
href=
"#"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Login
</a></li>
<li>
{% if request.user.is_authenticated %}
<a
href=
"{% url 'logout' %}"
>
<span
class=
"glyphicon glyphicon-log-out"
></span>
Logout
</a>
{% else %}
<a
href=
"{% url 'login' %}"
>
<span
class=
"glyphicon glyphicon-log-in"
></span>
Login
</a>
{% endif %}
</li>
</ul>
</div>
</div>
...
...
templates/registration/login.html
0 → 100644
View file @
fdbcbec0
{% extends "base.html" %}
{% load bootstrap3 %}
{% block title %}Login{% endblock %}
{% block content %}
{% if form.errors %}
<p>
Your username and password didn't match. Please try again.
</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>
Your account doesn't have access to this page. To proceed,
please login with an account that has access.
</p>
{% else %}
<p>
Please login to see this page.
</p>
{% endif %}
{% endif %}
<form
method=
"post"
action=
"{% url 'django.contrib.auth.views.login' %}"
>
{% csrf_token %}
{% bootstrap_form form %}
{% bootstrap_button "Login" button_type="submit" icon="log-in" %}
<input
type=
"hidden"
name=
"next"
value=
"{{ next }}"
/>
</form>
{# Assumes you setup the password_reset view in your URLconf #}
{#
<p><a
href=
"{% url 'password_reset' %}"
>
Lost password?
</a></p>
#}
{% endblock %}
Write
Preview
Supports
Markdown
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