add registration switch env

This commit is contained in:
finn 2024-08-08 16:10:43 +00:00
parent 92b314623a
commit 8f95303d11
4 changed files with 21 additions and 16 deletions

View File

@ -77,6 +77,9 @@ def logout():
def register(): def register():
if current_user.is_authenticated: if current_user.is_authenticated:
return redirect(url_for('index')) return redirect(url_for('index'))
if not app.config['ALLOW_REGISTRATION'] == "true":
flash('Registration temporarily disabled.')
return redirect(url_for('login'))
form = RegistrationForm() form = RegistrationForm()
if form.validate_on_submit(): if form.validate_on_submit():
user = User(username=form.username.data, email=form.email.data) user = User(username=form.username.data, email=form.email.data)

View File

@ -16,6 +16,7 @@ class Config:
ADMINS = [os.environ.get('DOTENV_ADMIN_EMAIL')] ADMINS = [os.environ.get('DOTENV_ADMIN_EMAIL')]
FROM_ADDRESS = os.environ.get('DOTENV_FROM_ADDRESS') FROM_ADDRESS = os.environ.get('DOTENV_FROM_ADDRESS')
REAL_HOSTNAME = os.environ.get('DOTENV_REAL_HOSTNAME') REAL_HOSTNAME = os.environ.get('DOTENV_REAL_HOSTNAME')
ALLOW_REGISTRATION = os.environ.get('DOTENV_ALLOW_REGISTRATION')
DC_LOGGING = True DC_LOGGING = True

View File

@ -44,6 +44,7 @@ services:
- DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM} - DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM}
- DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE} - DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE}
- DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME} - DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME}
- DOTENV_ALLOW_REGISTRATION=${ALLOW_REGISTRATION}
#ports: #ports:
# - 8000:8000 # - 8000:8000
expose: expose:

32
dotenv
View File

@ -1,30 +1,30 @@
# Example .env file # Example .env file
DOTENV_MYSQL_ROOT_PASSWORD_OLD=rootp DOTENV_MYSQL_ROOT_PASSWORD_OLD="aaa"
DOTENV_MYSQL_ROOT_PASSWORD=rootp DOTENV_MYSQL_ROOT_PASSWORD="aaa"
DOTENV_MYSQL_GITEA_PASSWORD=giteap DOTENV_MYSQL_GITEA_PASSWORD="aaa"
DOTENV_MYSQL_FLASK_PASSWORD=flaskp DOTENV_MYSQL_FLASK_PASSWORD="aaa"
GITEA_MAIL_FROM="git@e.e" GITEA_MAIL_FROM="git@aaa"
# Build ARG GPG_PP. May still need to be empty to avoid breakage. # Build ARG GPG_PP. May still need to be empty to avoid breakage.
BUILD_GPG_PP= BUILD_GPG_PP=
# Tor: # Tor:
# true/false # true/false:
USE_TOR=false USE_TOR=true
# Backend: # Backend:
FLASK_SECRET_KEY="aaa"
FLASK_SECRET_KEY="flaskkey"
# Inconsequential token: minimal inconvenience if exposed # Inconsequential token: minimal inconvenience if exposed
FLASK_TOKEN_I=dti FLASK_TOKEN_I="dti"
# Consequential token: protect # Consequential token: protect
FLASK_TOKEN_C=dtc FLASK_TOKEN_C="dtc"
# true/false:
FLASK_MAIL_FROM="git@e.e" ALLOW_REGISTRATION=true
FLASK_MAIL_FROM="git@aaa"
# admin email must be valid send from with mail subsystem # admin email must be valid send from with mail subsystem
FLASK_ADMIN_EMAIL="git@e.e" FLASK_ADMIN_EMAIL="git@aaa"
FLASK_JWT_PHRASE="tphrase" FLASK_JWT_PHRASE="aaa"
FLASK_REAL_HOSTNAME="localhost" FLASK_REAL_HOSTNAME="localhost"