mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 17:26:26 +01:00
Add config:DISABLE_REGISTER
This commit is contained in:
parent
782da97a1f
commit
3c018bc336
@ -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'
|
||||
|
@ -7,4 +7,9 @@ SECRET_KEY="dev"
|
||||
|
||||
# Port to run on
|
||||
PORT="5000"
|
||||
|
||||
# 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
|
@ -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"]
|
||||
|
@ -117,7 +117,9 @@
|
||||
<div class="username">{{ user.username }}</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{% if not config.DISABLE_REGISTER %}
|
||||
<a href="{{ url_for('auth.register') }}"><button>Créer un compte</button></a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('auth.login') }}"><button>Se connecter</button></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user