diff --git a/README.md b/README.md index 8e62e16..4963e96 100644 --- a/README.md +++ b/README.md @@ -70,5 +70,5 @@ Modifier le fichier de configuration créé dans `instance/` - [ ] Modifier son mot de passe - [ ] Supprimer un utilisateur - [ ] Ajouter config:DISABLE_DARK_MODE -- [ ] Ajouter config:DISABLE_REGISTER +- [x] Ajouter config:DISABLE_REGISTER - [ ] Ajouter config:ONLINE_SEARCH_BASE_QUERY pour la recherche google, actuellement 'filetype:pdf partition' diff --git a/default_config.py b/default_config.py index 70c9c5e..e3b0ac4 100644 --- a/default_config.py +++ b/default_config.py @@ -7,4 +7,9 @@ SECRET_KEY="dev" # Port to run on PORT="5000" -MAX_ONLINE_QUERIES=3 \ No newline at end of file + +# Number of online queries an "normal user" can do +MAX_ONLINE_QUERIES=3 + +# Disable registration of new users via /auth/register (they can still be added by root) +DISABLE_REGISTER=False \ No newline at end of file diff --git a/partitioncloud/modules/auth.py b/partitioncloud/modules/auth.py index 210f4f3..ad41d89 100644 --- a/partitioncloud/modules/auth.py +++ b/partitioncloud/modules/auth.py @@ -13,7 +13,8 @@ from flask import ( request, session, url_for, - flash + flash, + current_app ) from werkzeug.security import check_password_hash, generate_password_hash @@ -76,6 +77,10 @@ def register(): Validates that the username is not already taken. Hashes the password for security. """ + if current_app.config["DISABLE_REGISTER"]: + flash("L'enregistrement de nouveaux utilisateurs a été désactivé par l'administrateur.") + return redirect(url_for("auth.login")) + if request.method == "POST": username = request.form["username"] password = request.form["password"] diff --git a/partitioncloud/templates/base.html b/partitioncloud/templates/base.html index d8f54d3..8cc5c2e 100644 --- a/partitioncloud/templates/base.html +++ b/partitioncloud/templates/base.html @@ -117,7 +117,9 @@
{{ user.username }}
{% else %} - + {% if not config.DISABLE_REGISTER %} + + {% endif %} {% endif %}