From e3100e77b27a78049282306d6b326d34114a2bee Mon Sep 17 00:00:00 2001 From: John Doe Date: Mon, 22 Dec 2025 12:11:13 +0100 Subject: [PATCH] Add function set_mail_hostname --- tools/utils.py | 6 ++++++ views/inscription.py | 11 ++++++----- views/mymailbox.py | 10 +++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/utils.py b/tools/utils.py index c90d585..4dc2b75 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -50,6 +50,12 @@ def valid_username(username): return valid +def set_mail_domain(): + if MAIL_SERVER: + hostname = app.config['MAIL_DOMAIN'] + else: + hostname = None + def email_disp(email): disp = True diff --git a/views/inscription.py b/views/inscription.py index 67b36b3..f7ce23e 100644 --- a/views/inscription.py +++ b/views/inscription.py @@ -8,14 +8,13 @@ from tools.utils import email_disp, valid_token_register, valid_passwd, valid_us from socket import gethostname import subprocess from tools.filesutils import check_and_create - +from tools.utils import set_mail_domain app = Flask( 'pywallter' ) app.config.from_pyfile('config.py') bcrypt = Bcrypt(app) #### Variables ################################################################################## - DATAS_USER = app.config['DOSSIER_APP'] DOSSIER_PERSO = app.config['DOSSIER_APP'] extensionimg = app.config['EXT_IMG'] @@ -24,7 +23,7 @@ MAIL_SERVER = app.config['MAIL_SERVER'] XMPP_SERVER = app.config['XMPP_SERVER'] SETUID = app.config['SETUID'] BASE_URL = app.config['BASE_URL'] -MAIL_DOMAIN = app.config['MAIL_DOMAIN'] + ################################################################################################# @@ -33,7 +32,9 @@ inscription = Blueprint('inscription', __name__, template_folder='templates') @inscription.route( '/inscription/', methods=['GET','POST'] ) def signin(token) : - hostname = MAIL_DOMAIN + + mail_domain = set_mail_domain() + url_inscription = BASE_URL +'/inscription/'+token resp = None if valid_token_register(token, "Invitation"): @@ -44,7 +45,7 @@ def signin(token) : # Réponse si la requete est de type GET ou si la requete POST echoue resp = render_template('inscription.html', signin_enable=app.config['SIGNIN_ENABLE'], - token=token, hostname=hostname, + token=token, hostname=mail_domain, url_inscription=url_inscription, MAIL_SERVER=MAIL_SERVER, XMPP_SERVER=XMPP_SERVER) diff --git a/views/mymailbox.py b/views/mymailbox.py index daa48d1..2f5f7a3 100644 --- a/views/mymailbox.py +++ b/views/mymailbox.py @@ -7,7 +7,7 @@ import sqlite3 import os from shutil import copy from socket import gethostname -from tools.utils import email_disp, append_to_log, gen_token, valid_passwd, login_required +from tools.utils import email_disp, append_to_log, gen_token, valid_passwd, login_required, set_mail_domain @@ -28,11 +28,9 @@ MAIL_SERVER = app.config['MAIL_SERVER'] XMPP_SERVER = app.config['XMPP_SERVER'] SETUID = app.config['SETUID'] BASE_URL = app.config['BASE_URL'] -MAIL_DOMAIN = app.config['MAIL_DOMAIN'] MAIL_WEBSERVICE = app.config['MAIL_WEBSERVICE'] XMPP_WEBSERVICE = app.config['XMPP_WEBSERVICE'] - ################################################################################################## @@ -42,7 +40,7 @@ XMPP_WEBSERVICE = app.config['XMPP_WEBSERVICE'] @login_required def mymessaging(): - hostname=MAIL_DOMAIN + hostname=set_mail_domain() user='%s' % escape(session['username']) conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée cursor = conn.cursor() # Création de l'objet "curseur" @@ -67,7 +65,9 @@ def mymessaging(): @mymailbox.route('/mymailbox/alias', methods=['GET', 'POST'] ) @login_required def myalias(): - hostname=MAIL_DOMAIN + + + hostname = set_mail_domain() user='%s' % escape(session['username']) conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée cursor = conn.cursor() # Création de l'objet "curseur"