From 08b476851ebc032a20c8f2aee9b4ec5939482ff5 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 9 Nov 2024 07:35:22 +0100 Subject: [PATCH] password recovery integrated --- config_example/config.py | 47 +++++++++++++++++++++++++++++++++++----- main/settings.py | 26 ++++++++++++++++++---- themes | 2 +- users | 2 +- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/config_example/config.py b/config_example/config.py index 4b4d751..88c938c 100644 --- a/config_example/config.py +++ b/config_example/config.py @@ -1,18 +1,49 @@ ####################################################################### # Configuration of your django application ####################################################################### -# -# Users library -# -# This enables or disables the self registration -USERS_SELF_REGISTRATION = False - # # Themes library # # This defines the default theme, if no theme is set in the django parameters DEFAULT_THEME = 'clear-green' +# +# Users library +# +# This enables or disables the self registration +# If you enable self registration it is recommended to configure "Django mail / smtp settings" +USERS_SELF_REGISTRATION = False +# This enables or disables the mail validation after self registration +USERS_MAIL_VALIDATION = True +# This enables or disables the account activation by an admin after self registration +USERS_ADMIN_ACTIVATION = True +# The timeout for password recovery and mail validation tokens send via email +PASSWORD_RESET_TIMEOUT = 60 * 60 * 3 # 3 hours + +# +# Django mail / smtp settings +# +# The hostname of the smtp server +# EMAIL_HOST = "" +# The port used for the smtp connection +# EMAIL_PORT = +# The username for smtp authentication +# EMAIL_HOST_USER = "" +# The password for smtp authentication +# EMAIL_HOST_PASSWORD = "" +# The sender of piki emails +# EMAIL_FROM = "piki@" +# Set to True, if TLS shall be used +# EMAIL_USE_TLS = False +# Set to True, if SSL shall be used +# EMAIL_USE_SSL = True +# The smtp timeout +# EMAIL_TIMEOUT = +# Define a ssl keyfile +# EMAIL_SSL_KEYFILE = +# Define an ssl certificate +# EMAIL_SSL_CERTFILE = + # # Django # @@ -24,6 +55,10 @@ DEBUG = False # SECURITY WARNING: don't run with a dummy secret in production! And don't let others read this key! SECRET_KEY = None +# Define the administrators (for mail delivery) +ADMINS = [("PaTT", EMAIL_FROM), ] + + # This defines the listener hostnames for your django server # SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing! # ALLOWED_HOSTS = ['', ] diff --git a/main/settings.py b/main/settings.py index e99542e..2c7aa0e 100644 --- a/main/settings.py +++ b/main/settings.py @@ -7,7 +7,7 @@ For more information on this file, see https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.0/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path @@ -24,7 +24,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # Application definition @@ -41,6 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + # 'simple_history', ] @@ -180,6 +181,20 @@ USER_CONFIG_DEFAULTS = { 'DEFAULT_THEME': 'clear-green', 'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ], 'CSRF_TRUSTED_ORIGINS': [], + 'ADMINS': [], + 'PASSWORD_RESET_TIMEOUT': 60*60*3, + # + 'EMAIL_HOST': None, + 'EMAIL_PORT': None, + 'EMAIL_HOST_USER': None, + 'EMAIL_FROM': "piki", + 'EMAIL_HOST_PASSWORD': None, + 'EMAIL_USE_TLS': None, + 'EMAIL_USE_SSL': None, + 'EMAIL_TIMEOUT': None, + 'EMAIL_SSL_KEYFILE': None, + 'EMAIL_SSL_CERTFILE': None, + } # Set configuration parameters @@ -188,9 +203,12 @@ thismodule = sys.modules[__name__] for property_name in USER_CONFIG_DEFAULTS: try: value = getattr(config, property_name) + setattr(thismodule, property_name, value) except AttributeError: - value = USER_CONFIG_DEFAULTS[property_name] - setattr(thismodule, property_name, value) + if not property_name.startswith('EMAIL_') or property_name == 'EMAIL_FROM': + value = USER_CONFIG_DEFAULTS[property_name] + setattr(thismodule, property_name, value) + # SECURITY WARNING: keep the secret key used in production secret! # diff --git a/themes b/themes index 47e9f31..b7673fa 160000 --- a/themes +++ b/themes @@ -1 +1 @@ -Subproject commit 47e9f3104c5016ef9405c90ee5dfca6e638e7d82 +Subproject commit b7673fa82763830009c7dc95ecf93d7e96f692f9 diff --git a/users b/users index 3a24ee2..12526f4 160000 --- a/users +++ b/users @@ -1 +1 @@ -Subproject commit 3a24ee2459d25b71cbd6cf79e486ccbf3567b928 +Subproject commit 12526f44d736b360a2c92a46eabed1c455e1b4fa