Commit fdbcbec0 authored by lhark's avatar lhark

Add login system

parent 47f930b0
......@@ -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/'
......@@ -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')),
......
......@@ -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>
......
{% 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 %}
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