Correction de bugs inscription et changements de MDP
This commit is contained in:
parent
4a278699d9
commit
87a088f54d
@ -38,14 +38,17 @@ def signin(token) :
|
|||||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||||
user = request.form['user']
|
user = request.form['user']
|
||||||
mail = request.form['mail']+'@'+hostname
|
mail = request.form['mail']+'@'+hostname
|
||||||
passwd = bcrypt.generate_password_hash(request.form['passwd'])
|
passwd = request.form['passwd']
|
||||||
|
|
||||||
passwdconfirm = request.form['passwdconfirm']
|
passwdconfirm = request.form['passwdconfirm']
|
||||||
|
bcrypt_passwd = bcrypt.generate_password_hash(request.form['passwd'])
|
||||||
cursor.execute("""SELECT name FROM users WHERE name=?""", (user,))
|
cursor.execute("""SELECT name FROM users WHERE name=?""", (user,))
|
||||||
testuser = cursor.fetchone()
|
testuser = cursor.fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
if MAIL_SERVER:
|
if MAIL_SERVER:
|
||||||
p = run( [ SETUID, 'set_mail_passwd', "'"+mailbox['Mail']+"'", "'"+passwd+"'" ] )
|
cmd = SETUID + " set_mail_passwd " + "'"+mail+"' " + "'"+passwd+"'"
|
||||||
|
mail_passwd_change = os.system(cmd)
|
||||||
|
|
||||||
|
|
||||||
if testuser:
|
if testuser:
|
||||||
@ -54,45 +57,46 @@ def signin(token) :
|
|||||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||||
hostname=hostname)
|
hostname=hostname)
|
||||||
|
|
||||||
elif not(email_disp(mail)) or p.returncode != 0 :
|
elif not(email_disp(mail)) or mail_passwd_change != 0 :
|
||||||
flash(u'Adresse email déjà utilisé, merci d\'en choisir un autre', 'error')
|
flash(u'Adresse email déjà utilisé, merci d\'en choisir un autre', 'error')
|
||||||
resp = render_template('inscription.html',
|
resp = render_template('inscription.html',
|
||||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||||
hostname=hostname)
|
hostname=hostname)
|
||||||
else:
|
else:
|
||||||
confirmation = bcrypt.check_password_hash(passwd, passwdconfirm)
|
confirmation = bcrypt.check_password_hash(bcrypt_passwd, passwdconfirm)
|
||||||
if confirmation is True:
|
if confirmation is True:
|
||||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||||
cursor.execute("""INSERT INTO users(name, mail, passwd) VALUES(?, ?, ?)""", (user, mail, passwd)) # Insérer des valeurs
|
cursor.execute("""INSERT INTO users(name, mail, passwd) VALUES(?, ?, ?)""", (user, mail, bcrypt_passwd)) # Insérer des valeurs
|
||||||
conn.commit() # Sauvegarder valeurs dans la bdd
|
conn.commit() # Sauvegarder valeurs dans la bdd
|
||||||
|
|
||||||
|
|
||||||
if XMMP_SERVER:
|
if XMMP_SERVER:
|
||||||
tmp = mailbox['mail'].split('@')
|
tmp = mail.split('@')
|
||||||
p = run( [ SETUID, 'prosodyctl register ', "'"+tmp[0]+"'",
|
cmd = SETUID+ ' prosodyctl register ' "'"+tmp[0]+"' " + "'"+tmp[1]+"' " + "'"+passwd+"'"
|
||||||
"'"+tmp[1]+"'", "'"+passwd+"'" ])
|
res = os.system(cmd)
|
||||||
if p.returncode != 0:
|
if res != 0:
|
||||||
flash(u'Il y a eu un problème lors de la création du compte XMPP !', 'error')
|
flash(u'Il y a eu un problème pour la création du compte XMPP !', 'error')
|
||||||
|
|
||||||
cursor.execute("""SELECT name, mail, passwd FROM users""")
|
cursor.execute("""SELECT name, mail, passwd FROM users""")
|
||||||
|
|
||||||
users = cursor.fetchall()
|
users = cursor.fetchall()
|
||||||
for i in users:
|
for i in users:
|
||||||
i = print('{0} - {1} - {2}'.format(i[0], i[1], i[2]))
|
i = print('{0} - {1} - {2}'.format(i[0], i[1], i[2]))
|
||||||
conn.close()
|
|
||||||
userracine = DOSSIER_PERSO + user
|
userracine = DOSSIER_PERSO + user
|
||||||
userfiles = userracine + '/files'
|
userfiles = userracine + '/files'
|
||||||
userimages = userracine + '/images'
|
userimages = userracine + '/images'
|
||||||
userthumbnails = userracine + '/images/thumbnails'
|
userthumbnails = userracine + '/images/thumbnails'
|
||||||
userprofile = userracine + '/profile'
|
userprofile = userracine + '/profile'
|
||||||
|
userlog = userracine + '/log.txt'
|
||||||
if not os.path.exists(userracine):
|
if not os.path.exists(userracine):
|
||||||
os.makedirs(userracine)
|
os.makedirs(userracine)
|
||||||
os.makedirs(userfiles)
|
os.makedirs(userfiles)
|
||||||
os.makedirs(userimages)
|
os.makedirs(userimages)
|
||||||
os.makedirs(userthumbnails)
|
os.makedirs(userthumbnails)
|
||||||
os.makedirs(userprofile)
|
os.makedirs(userprofile)
|
||||||
fp = open('log.txt', 'x')
|
fp = open(userlog, 'x')
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +116,7 @@ def signin(token) :
|
|||||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||||
hostname=hostname)
|
hostname=hostname)
|
||||||
else :
|
else :
|
||||||
url_inscription = BASE_URL+'invitation/'+token
|
url_inscription = BASE_URL+'inscription/'+token
|
||||||
resp = render_template('inscription.html',
|
resp = render_template('inscription.html',
|
||||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||||
token=token, hostname=hostname, url_inscription=url_inscription)
|
token=token, hostname=hostname, url_inscription=url_inscription)
|
||||||
|
@ -5,7 +5,6 @@ import time
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
from socket import gethostname
|
from socket import gethostname
|
||||||
from subprocess import run
|
|
||||||
from flask_bcrypt import Bcrypt
|
from flask_bcrypt import Bcrypt
|
||||||
from tools.utils import email_disp, append_to_log, gen_token
|
from tools.utils import email_disp, append_to_log, gen_token
|
||||||
|
|
||||||
@ -130,14 +129,15 @@ def change_passwd() :
|
|||||||
passwd = request.form['password']
|
passwd = request.form['password']
|
||||||
|
|
||||||
if MAIL_SERVER:
|
if MAIL_SERVER:
|
||||||
p = run( [ SETUID, 'set_mail_passwd', "'"+mailbox['Mail']+"'", "'"+passwd+"'" ] )
|
cmd = SETUID+ " set_mail_passwd " + "'"+mailbox['Mail']+"' "+"'"+passwd+"'"
|
||||||
mail_passwd_change = p.returncode
|
mail_passwd_change = os.system(cmd)
|
||||||
|
|
||||||
if XMMP_SERVER:
|
|
||||||
tmp = mailbox['mail'].split('@')
|
if XMPP_SERVER:
|
||||||
p = run( [ SETUID, 'prosodyctl register', "'"+tmp[0]+"'",
|
tmp = mailbox['Mail'].split('@')
|
||||||
"'"+tmp[1]+"'", "'"+passwd+"'" ])
|
cmd = SETUID+ " prosodyctl register '"+tmp[0]+"' " + "'"+tmp[1]+"' " + "'"+passwd+"'"
|
||||||
if p.returncode != 0:
|
res = os.system(cmd)
|
||||||
|
if res != 0:
|
||||||
flash(u'Il y a eu un problème pour le changement du mot de passe du compte XMPP !', 'error')
|
flash(u'Il y a eu un problème pour le changement du mot de passe du compte XMPP !', 'error')
|
||||||
|
|
||||||
|
|
||||||
@ -189,8 +189,9 @@ def myalias():
|
|||||||
aliases = alias_list + "," +alias
|
aliases = alias_list + "," +alias
|
||||||
else:
|
else:
|
||||||
aliases = alias
|
aliases = alias
|
||||||
p = run( [ 'set_mail_alias', "'"+mail+"'", "add", "'"+alias+"'" ] )
|
cmd = SETUID+ " set_mail_alias " + "'"+mail+"'"+" add "+"'"+alias+"'"
|
||||||
if p.returncode == 0:
|
res = os.system(cmd)
|
||||||
|
if res == 0:
|
||||||
cursor.execute("UPDATE users SET alias=? WHERE name=?",
|
cursor.execute("UPDATE users SET alias=? WHERE name=?",
|
||||||
(aliases, UTILISATEUR))
|
(aliases, UTILISATEUR))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@ -245,8 +246,9 @@ def remove_alias(aliasrm):
|
|||||||
aliases = aliases + "," + alias
|
aliases = aliases + "," + alias
|
||||||
else:
|
else:
|
||||||
aliases = alias
|
aliases = alias
|
||||||
p = run( [ 'set_mail_alias', "'"+mail+"'", "del", "'"+alias+"'" ] )
|
cmd = SETUID+ " set_mail_alias " + "'"+mail+"'"+" del "+"'"+alias+"'"
|
||||||
if p.returncode == 0:
|
res = os.system(cmd)
|
||||||
|
if res == 0:
|
||||||
cursor.execute("UPDATE users SET alias=? WHERE name=?",
|
cursor.execute("UPDATE users SET alias=? WHERE name=?",
|
||||||
(aliases, UTILISATEUR))
|
(aliases, UTILISATEUR))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user