Add function set_mail_hostname

This commit is contained in:
kitoy 2025-12-22 12:11:13 +01:00
parent 481e179833
commit e3100e77b2
3 changed files with 17 additions and 10 deletions

View File

@ -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

View File

@ -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/<token>', 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)

View File

@ -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"