8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 08:53:46 +00:00

Add login system

This commit is contained in:
lhark 2016-07-08 20:11:53 +02:00
parent c2c5321b81
commit 7f3354e355
4 changed files with 52 additions and 3 deletions

View file

@ -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/'

View file

@ -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')),

View file

@ -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>

View file

@ -0,0 +1,32 @@
{% 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 %}