feat: Add basic user handling
This commit is contained in:
parent
9af46290fa
commit
e3ee4a2d32
@ -34,6 +34,7 @@ dependencies = [
|
|||||||
"model_bakery",
|
"model_bakery",
|
||||||
"markdown",
|
"markdown",
|
||||||
"Pillow",
|
"Pillow",
|
||||||
|
"django-registration"
|
||||||
]
|
]
|
||||||
dynamic = ["version", "readme"]
|
dynamic = ["version", "readme"]
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
@ -35,4 +35,7 @@ urlpatterns = [
|
|||||||
# ex: user/1
|
# ex: user/1
|
||||||
path("user/<int:user_id>/", views.member_detail, name="user-detail"),
|
path("user/<int:user_id>/", views.member_detail, name="user-detail"),
|
||||||
|
|
||||||
|
path('accounts/', include('django_registration.backends.activation.urls')),
|
||||||
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -76,6 +76,10 @@ else:
|
|||||||
EMAIL_USE_TLS = config.getboolean('mail', 'tls', fallback=False)
|
EMAIL_USE_TLS = config.getboolean('mail', 'tls', fallback=False)
|
||||||
EMAIL_USE_SSL = config.getboolean('mail', 'ssl', 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 """
|
""" SECURITY.TXT """
|
||||||
SEC_CONTACT = config.get("security", "Contact", fallback="julian-samuel@gebuehr.net")
|
SEC_CONTACT = config.get("security", "Contact", fallback="julian-samuel@gebuehr.net")
|
||||||
|
8
src/templates/django_registration/activate.html
Normal file
8
src/templates/django_registration/activate.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{% extends "fellchensammlung/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<p>{% translate "Account activation failed" %}</p>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -0,0 +1,6 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>{% translate "You are now activated. Have fun." %}</p>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,8 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
{% trans "Activate account at" %} {{ site.name }}:
|
||||||
|
|
||||||
|
<a href="{{ site.domain }}{% url 'django_registration_activate' activation_key%}">{% trans "Activate by clicking this link" %}</a>
|
||||||
|
{% 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 %}
|
@ -0,0 +1 @@
|
|||||||
|
{% load i18n %}{% translate "Account activation on" %} {{ site.name }}
|
6
src/templates/django_registration/activation_failed.html
Normal file
6
src/templates/django_registration/activation_failed.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>{% translate "Activation failed. Please send an e-mail to info@notfellchen.org to get an account." %}</p>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,6 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>{% translate "Registration is currently closed." %}</p>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,6 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>{% translate "You are now registered. Activation email sent." %}</p>
|
||||||
|
{% endblock %}
|
15
src/templates/django_registration/registration_form.html
Normal file
15
src/templates/django_registration/registration_form.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if not user.is_authenticated %}
|
||||||
|
<form method="post" action=".">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
|
||||||
|
<input type="submit" value="{% translate 'Submit' %}" />
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<p>{% translate "You're already logged in." %}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
7
src/templates/registration/logged_out.html
Normal file
7
src/templates/registration/logged_out.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>{% translate "Logged out" %}!</p>
|
||||||
|
<a href="{% url 'login'%}">{% translate "Click here to login again." %}</a>
|
||||||
|
{% endblock %}
|
36
src/templates/registration/login.html
Normal file
36
src/templates/registration/login.html
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% if form.errors %}
|
||||||
|
<p>{% translate "Your username and password didn't match. Please try again." %}</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<p>{% translate "You're already logged in." %}</p>
|
||||||
|
{% else %} {% if next %}
|
||||||
|
<p>{% translate "Please login to see this page." %}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if not user.is_authenticated %}
|
||||||
|
<form method="post" action="{% url 'login' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>{{ form.username.label_tag }}</td>
|
||||||
|
<td>{{ form.username }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ form.password.label_tag }}</td>
|
||||||
|
<td>{{ form.password }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<input type="submit" value={% translate "login" %} />
|
||||||
|
<input type="hidden" name="next" value="{{ next }}" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p><a href="{% url 'password_reset' %}">{% translate "Lost password?" %}</a></p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
7
src/templates/registration/password_reset_complete.html
Normal file
7
src/templates/registration/password_reset_complete.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{% translate "The password has been changed!" %}</h1>
|
||||||
|
<p><a href="{% url 'login' %}">log in again?</a></p>
|
||||||
|
{% endblock %}
|
31
src/templates/registration/password_reset_confirmation.html
Normal file
31
src/templates/registration/password_reset_confirmation.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if validlink %}
|
||||||
|
<p>{% translate "Please enter (and confirm) your new password." %}</p>
|
||||||
|
<form action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>{{ form.new_password1.errors }}
|
||||||
|
<label for="id_new_password1">{% translate "New password" %}:</label></td>
|
||||||
|
<td>{{ form.new_password1 }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ form.new_password2.errors }}
|
||||||
|
<label for="id_new_password2">{% translate "Confirm password" %}:</label></td>
|
||||||
|
<td>{{ form.new_password2 }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td><input type="submit" value={% translate "Change my password" %} /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<h1>{% translate "Password reset failed" %}</h1>
|
||||||
|
<p>{% translate "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
6
src/templates/registration/password_reset_done.html
Normal file
6
src/templates/registration/password_reset_done.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>{% translate "We've emailed you instructions for setting your password. If they haven't arrived in a few minutes, check your spam folder." %}</p>
|
||||||
|
{% endblock %}
|
3
src/templates/registration/password_reset_email.html
Normal file
3
src/templates/registration/password_reset_email.html
Normal file
@ -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 %}
|
15
src/templates/registration/password_reset_form.html
Normal file
15
src/templates/registration/password_reset_form.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% extends "fellchensammlung/base_generic.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<form action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% if form.email.errors %}
|
||||||
|
{{ form.email.errors }}
|
||||||
|
{% endif %}
|
||||||
|
<h1> {% translate "Password reset" %} </h1>
|
||||||
|
<p>{% translate "Provide the e-mail address that is connected with your account" %}</p>
|
||||||
|
<p>{{ form.email }}</p>
|
||||||
|
<input type="submit" class="btn btn-default btn-lg" value={% translate "Reset" %}>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user