Merge branch 'auth-login' of https://github.com/plepe/umap into plepe-auth-login
This commit is contained in:
commit
2437334940
8 changed files with 73 additions and 0 deletions
|
@ -14,3 +14,8 @@ def version(request):
|
|||
return {
|
||||
'UMAP_VERSION': __version__
|
||||
}
|
||||
|
||||
def authentication(request):
|
||||
return {
|
||||
'ENABLE_ACCOUNT_LOGIN': settings.ENABLE_ACCOUNT_LOGIN
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ TEMPLATES = [
|
|||
'social.apps.django_app.context_processors.login_redirect',
|
||||
'umap.context_processors.settings',
|
||||
'umap.context_processors.version',
|
||||
'umap.context_processors.authentication',
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -142,6 +143,7 @@ MIDDLEWARE_CLASSES = (
|
|||
# Auth / security
|
||||
# =============================================================================
|
||||
|
||||
ENABLE_ACCOUNT_LOGIN = True
|
||||
AUTHENTICATION_BACKENDS += (
|
||||
)
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@ COMPRESS_OFFLINE = True
|
|||
|
||||
LANGUAGE_CODE = 'en'
|
||||
|
||||
# Set to False if login into django account should not be possible. You can
|
||||
# administer accounts in the admin interface.
|
||||
ENABLE_ACCOUNT_LOGIN = True
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'social.backends.github.GithubOAuth2',
|
||||
'social.backends.bitbucket.BitbucketOAuth',
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% if ENABLE_ACCOUNT_LOGIN %}
|
||||
<h5>{% trans "Please log in with your account" %}</h5>
|
||||
|
||||
<div>
|
||||
{% if form.non_field_errors %}
|
||||
<ul class='form-errors'>
|
||||
{% for error in form.non_field_errors %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<form id='login_form' action="{% url 'login' %}" method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="text" name="username" placeholder="{% trans 'Username' %}" autofocus />
|
||||
<input type="password" name="password" placeholder="{% trans 'Password' %}" />
|
||||
<input type="submit" value="{% trans 'Login' %}" />
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if backends.backends|length %}
|
||||
<h5>{% trans "Please choose a provider" %}</h5>
|
||||
<div>
|
||||
<ul class="login-grid block-grid">
|
||||
|
@ -10,3 +32,4 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
<li><a href="{% url 'about' %}">{% trans "About" %}</a></li>
|
||||
<li class="mhide"><a href="{{ UMAP_FEEDBACK_LINK }}">{% trans "Feedback" %}</a></li>
|
||||
{% if user.is_authenticated %}
|
||||
{% if user.has_usable_password %}
|
||||
<li><a href="{% url 'password_change' %}" >{% trans "Change password" %}</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{% url 'logout' %}" class="logout">{% trans "Log out" %}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
20
umap/templates/umap/password_change.html
Normal file
20
umap/templates/umap/password_change.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
{% extends "umap/content.html" %}
|
||||
|
||||
{% load leaflet_storage_tags i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h2 class="section">{% trans "Password change" %}</h2>
|
||||
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
|
||||
|
||||
<form action="{% url 'password_change' %}" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form.old_password.errors }}
|
||||
<input type='password' name='old_password' placeholder='{% trans "Old password" %}' autofocus />
|
||||
{{ form.new_password1.errors }}
|
||||
<input type='password' name='new_password1' placeholder='{% trans "New password" %}' />
|
||||
{{ form.new_password2.errors }}
|
||||
<input type='password' name='new_password2' placeholder='{% trans "New password confirmation" %}' />
|
||||
|
||||
<input type='submit' value='{% trans "Change my password" %}' />
|
||||
</form>
|
||||
{% endblock content %}
|
9
umap/templates/umap/password_change_done.html
Normal file
9
umap/templates/umap/password_change_done.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "umap/content.html" %}
|
||||
|
||||
{% load leaflet_storage_tags i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h2 class="section">{% trans "Password change successful" %}</h2>
|
||||
<p>{% trans "Your password was changed." %}</p>
|
||||
<p><a href="{% url 'home' %}">Home</a></p>
|
||||
{% endblock content %}
|
|
@ -5,6 +5,7 @@ from django.conf.urls import url, include
|
|||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.contrib import admin
|
||||
from django.views.decorators.cache import cache_page
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
from leaflet_storage.views import MapShortUrl
|
||||
|
||||
|
@ -18,6 +19,12 @@ urlpatterns = [
|
|||
url(r'^m/(?P<pk>\d+)/$', MapShortUrl.as_view(), name='umap_short_url'),
|
||||
url(r'^ajax-proxy/$', cache_page(180)(views.ajax_proxy),
|
||||
name='ajax-proxy'),
|
||||
url(r'^change-password/', auth_views.password_change,
|
||||
{'template_name': 'umap/password_change.html'},
|
||||
name='password_change'),
|
||||
url(r'^change-password-done/', auth_views.password_change_done,
|
||||
{'template_name': 'umap/password_change_done.html'},
|
||||
name='password_change_done'),
|
||||
]
|
||||
urlpatterns += i18n_patterns(
|
||||
url(r'^$', views.home, name="home"),
|
||||
|
|
Loading…
Reference in a new issue