diff --git a/umap/context_processors.py b/umap/context_processors.py index 26c1c0f0..c6bdf6dc 100644 --- a/umap/context_processors.py +++ b/umap/context_processors.py @@ -14,3 +14,8 @@ def version(request): return { 'UMAP_VERSION': __version__ } + +def authentication(request): + return { + 'ENABLE_ACCOUNT_LOGIN': settings.ENABLE_ACCOUNT_LOGIN + } diff --git a/umap/settings/base.py b/umap/settings/base.py index a308f2c0..a72d9f45 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -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 += ( ) diff --git a/umap/settings/local.py.sample b/umap/settings/local.py.sample index ec5e208d..c74756fa 100644 --- a/umap/settings/local.py.sample +++ b/umap/settings/local.py.sample @@ -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', diff --git a/umap/templates/registration/login.html b/umap/templates/registration/login.html index eb5b8783..49bb6432 100644 --- a/umap/templates/registration/login.html +++ b/umap/templates/registration/login.html @@ -1,5 +1,27 @@ {% load i18n %} +{% if ENABLE_ACCOUNT_LOGIN %} +
{% trans "Please log in with your account" %}
+ +
+ {% if form.non_field_errors %} + + {% endif %} + +
+ {% csrf_token %} + + + +
+
+{% endif %} + +{% if backends.backends|length %}
{% trans "Please choose a provider" %}
+{% endif %} diff --git a/umap/templates/umap/navigation.html b/umap/templates/umap/navigation.html index 970d3c1b..3574e636 100644 --- a/umap/templates/umap/navigation.html +++ b/umap/templates/umap/navigation.html @@ -16,6 +16,9 @@
  • {% trans "About" %}
  • {% trans "Feedback" %}
  • {% if user.is_authenticated %} + {% if user.has_usable_password %} +
  • {% trans "Change password" %}
  • + {% endif %}
  • {% trans "Log out" %}
  • {% endif %} diff --git a/umap/templates/umap/password_change.html b/umap/templates/umap/password_change.html new file mode 100644 index 00000000..0f030247 --- /dev/null +++ b/umap/templates/umap/password_change.html @@ -0,0 +1,20 @@ +{% extends "umap/content.html" %} + +{% load leaflet_storage_tags i18n %} + +{% block content %} +

    {% trans "Password change" %}

    +

    {% 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." %}

    + +
    + {% csrf_token %} + {{ form.old_password.errors }} + + {{ form.new_password1.errors }} + + {{ form.new_password2.errors }} + + + +
    +{% endblock content %} diff --git a/umap/templates/umap/password_change_done.html b/umap/templates/umap/password_change_done.html new file mode 100644 index 00000000..039e6121 --- /dev/null +++ b/umap/templates/umap/password_change_done.html @@ -0,0 +1,9 @@ +{% extends "umap/content.html" %} + +{% load leaflet_storage_tags i18n %} + +{% block content %} +

    {% trans "Password change successful" %}

    +

    {% trans "Your password was changed." %}

    +

    Home

    +{% endblock content %} diff --git a/umap/urls.py b/umap/urls.py index e41bac2f..322c124f 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -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\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"),