diff --git a/pyproject.toml b/pyproject.toml index f4e731d..067e9c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ dependencies = [ "model_bakery", "markdown", "Pillow", + "django-registration" ] dynamic = ["version", "readme"] diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index af482a7..13289be 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -1,4 +1,4 @@ -from django.urls import path +from django.urls import path, include from . import views @@ -35,4 +35,7 @@ urlpatterns = [ # ex: user/1 path("user//", views.member_detail, name="user-detail"), + path('accounts/', include('django_registration.backends.activation.urls')), + path('accounts/', include('django.contrib.auth.urls')), + ] diff --git a/src/notfellchen/settings.py b/src/notfellchen/settings.py index 9a6ba0b..09a30d6 100644 --- a/src/notfellchen/settings.py +++ b/src/notfellchen/settings.py @@ -76,6 +76,10 @@ else: EMAIL_USE_TLS = config.getboolean('mail', 'tls', fallback=False) EMAIL_USE_SSL = config.getboolean('mail', 'ssl', fallback=False) +"""USER MANAGEMENT""" +ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window +REGISTRATION_OPEN = True +REGISTRATION_SALT = "notfellchen" """ SECURITY.TXT """ SEC_CONTACT = config.get("security", "Contact", fallback="julian-samuel@gebuehr.net") diff --git a/src/templates/django_registration/activate.html b/src/templates/django_registration/activate.html new file mode 100644 index 0000000..ffa9310 --- /dev/null +++ b/src/templates/django_registration/activate.html @@ -0,0 +1,8 @@ +{% extends "fellchensammlung/base.html" %} +{% load i18n %} + +{% block content %} + +

{% translate "Account activation failed" %}

+ +{% endblock %} \ No newline at end of file diff --git a/src/templates/django_registration/activation_complete.html b/src/templates/django_registration/activation_complete.html new file mode 100644 index 0000000..aa13d38 --- /dev/null +++ b/src/templates/django_registration/activation_complete.html @@ -0,0 +1,6 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "You are now activated. Have fun." %}

+{% endblock %} \ No newline at end of file diff --git a/src/templates/django_registration/activation_email_body.txt b/src/templates/django_registration/activation_email_body.txt new file mode 100644 index 0000000..dbf5dfe --- /dev/null +++ b/src/templates/django_registration/activation_email_body.txt @@ -0,0 +1,8 @@ +{% load i18n %} +{% trans "Activate account at" %} {{ site.name }}: + +{% trans "Activate by clicking this link" %} +{% trans "or open the following link in your browser" %}: +{{ site.domain }}{% url 'django_registration_activate' activation_key%} + +{% blocktrans %}Link is valid for {{ expiration_days }} days.{% endblocktrans %} \ No newline at end of file diff --git a/src/templates/django_registration/activation_email_subject.txt b/src/templates/django_registration/activation_email_subject.txt new file mode 100644 index 0000000..2e5501b --- /dev/null +++ b/src/templates/django_registration/activation_email_subject.txt @@ -0,0 +1 @@ +{% load i18n %}{% translate "Account activation on" %} {{ site.name }} \ No newline at end of file diff --git a/src/templates/django_registration/activation_failed.html b/src/templates/django_registration/activation_failed.html new file mode 100644 index 0000000..527af21 --- /dev/null +++ b/src/templates/django_registration/activation_failed.html @@ -0,0 +1,6 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "Activation failed. Please send an e-mail to info@notfellchen.org to get an account." %}

+{% endblock %} \ No newline at end of file diff --git a/src/templates/django_registration/registration_closed.html b/src/templates/django_registration/registration_closed.html new file mode 100644 index 0000000..364a1e0 --- /dev/null +++ b/src/templates/django_registration/registration_closed.html @@ -0,0 +1,6 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "Registration is currently closed." %}

+{% endblock %} \ No newline at end of file diff --git a/src/templates/django_registration/registration_complete.html b/src/templates/django_registration/registration_complete.html new file mode 100644 index 0000000..d2e9675 --- /dev/null +++ b/src/templates/django_registration/registration_complete.html @@ -0,0 +1,6 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "You are now registered. Activation email sent." %}

+{% endblock %} \ No newline at end of file diff --git a/src/templates/django_registration/registration_form.html b/src/templates/django_registration/registration_form.html new file mode 100644 index 0000000..addd997 --- /dev/null +++ b/src/templates/django_registration/registration_form.html @@ -0,0 +1,15 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +{% if not user.is_authenticated %} +
+ {% csrf_token %} + {{ form.as_p }} + + +
+{% else %} +

{% translate "You're already logged in." %}

+{% endif %} +{% endblock %} \ No newline at end of file diff --git a/src/templates/registration/logged_out.html b/src/templates/registration/logged_out.html new file mode 100644 index 0000000..d526c8b --- /dev/null +++ b/src/templates/registration/logged_out.html @@ -0,0 +1,7 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "Logged out" %}!

+ {% translate "Click here to login again." %} +{% endblock %} diff --git a/src/templates/registration/login.html b/src/templates/registration/login.html new file mode 100644 index 0000000..359a297 --- /dev/null +++ b/src/templates/registration/login.html @@ -0,0 +1,36 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} + + {% if form.errors %} +

{% translate "Your username and password didn't match. Please try again." %}

+ {% endif %} + +{% if user.is_authenticated %} +

{% translate "You're already logged in." %}

+ {% else %} {% if next %} +

{% translate "Please login to see this page." %}

+ {% endif %} +{% endif %} + +{% if not user.is_authenticated %} +
+ {% csrf_token %} + + + + + + + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+ + +
+ +

{% translate "Lost password?" %}

+{% endif %} +{% endblock %} \ No newline at end of file diff --git a/src/templates/registration/password_reset_complete.html b/src/templates/registration/password_reset_complete.html new file mode 100644 index 0000000..be723dc --- /dev/null +++ b/src/templates/registration/password_reset_complete.html @@ -0,0 +1,7 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "The password has been changed!" %}

+

log in again?

+{% endblock %} diff --git a/src/templates/registration/password_reset_confirmation.html b/src/templates/registration/password_reset_confirmation.html new file mode 100644 index 0000000..6bc0fe8 --- /dev/null +++ b/src/templates/registration/password_reset_confirmation.html @@ -0,0 +1,31 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} + {% if validlink %} +

{% translate "Please enter (and confirm) your new password." %}

+
+ {% csrf_token %} + + + + + + + + + + + + + +
{{ form.new_password1.errors }} + {{ form.new_password1 }}
{{ form.new_password2.errors }} + {{ form.new_password2 }}
+
+ {% else %} +

{% translate "Password reset failed" %}

+

{% translate "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}

+ {% endif %} +{% endblock %} + diff --git a/src/templates/registration/password_reset_done.html b/src/templates/registration/password_reset_done.html new file mode 100644 index 0000000..d0c335d --- /dev/null +++ b/src/templates/registration/password_reset_done.html @@ -0,0 +1,6 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +

{% translate "We've emailed you instructions for setting your password. If they haven't arrived in a few minutes, check your spam folder." %}

+ {% endblock %} diff --git a/src/templates/registration/password_reset_email.html b/src/templates/registration/password_reset_email.html new file mode 100644 index 0000000..74f8b7f --- /dev/null +++ b/src/templates/registration/password_reset_email.html @@ -0,0 +1,3 @@ +{% load i18n %} +{% translate "Someone asked for password reset for your email. Follow the link below:" %} +{{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} diff --git a/src/templates/registration/password_reset_form.html b/src/templates/registration/password_reset_form.html new file mode 100644 index 0000000..c0a9ac6 --- /dev/null +++ b/src/templates/registration/password_reset_form.html @@ -0,0 +1,15 @@ +{% extends "fellchensammlung/base_generic.html" %} +{% load i18n %} + +{% block content %} +
+ {% csrf_token %} + {% if form.email.errors %} + {{ form.email.errors }} + {% endif %} +

{% translate "Password reset" %}

+

{% translate "Provide the e-mail address that is connected with your account" %}

+

{{ form.email }}

+ +
+{% endblock %}