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"
|
||||
user = request.form['user']
|
||||
mail = request.form['mail']+'@'+hostname
|
||||
passwd = bcrypt.generate_password_hash(request.form['passwd'])
|
||||
passwd = request.form['passwd']
|
||||
|
||||
passwdconfirm = request.form['passwdconfirm']
|
||||
bcrypt_passwd = bcrypt.generate_password_hash(request.form['passwd'])
|
||||
cursor.execute("""SELECT name FROM users WHERE name=?""", (user,))
|
||||
testuser = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
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:
|
||||
@ -54,45 +57,46 @@ def signin(token) :
|
||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||
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')
|
||||
resp = render_template('inscription.html',
|
||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||
hostname=hostname)
|
||||
else:
|
||||
confirmation = bcrypt.check_password_hash(passwd, passwdconfirm)
|
||||
confirmation = bcrypt.check_password_hash(bcrypt_passwd, passwdconfirm)
|
||||
if confirmation is True:
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
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
|
||||
|
||||
|
||||
if XMMP_SERVER:
|
||||
tmp = mailbox['mail'].split('@')
|
||||
p = run( [ SETUID, 'prosodyctl register ', "'"+tmp[0]+"'",
|
||||
"'"+tmp[1]+"'", "'"+passwd+"'" ])
|
||||
if p.returncode != 0:
|
||||
flash(u'Il y a eu un problème lors de la création du compte XMPP !', 'error')
|
||||
tmp = mail.split('@')
|
||||
cmd = SETUID+ ' prosodyctl register ' "'"+tmp[0]+"' " + "'"+tmp[1]+"' " + "'"+passwd+"'"
|
||||
res = os.system(cmd)
|
||||
if res != 0:
|
||||
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""")
|
||||
|
||||
users = cursor.fetchall()
|
||||
for i in users:
|
||||
i = print('{0} - {1} - {2}'.format(i[0], i[1], i[2]))
|
||||
conn.close()
|
||||
|
||||
userracine = DOSSIER_PERSO + user
|
||||
userfiles = userracine + '/files'
|
||||
userimages = userracine + '/images'
|
||||
userthumbnails = userracine + '/images/thumbnails'
|
||||
userprofile = userracine + '/profile'
|
||||
userlog = userracine + '/log.txt'
|
||||
if not os.path.exists(userracine):
|
||||
os.makedirs(userracine)
|
||||
os.makedirs(userfiles)
|
||||
os.makedirs(userimages)
|
||||
os.makedirs(userthumbnails)
|
||||
os.makedirs(userprofile)
|
||||
fp = open('log.txt', 'x')
|
||||
fp = open(userlog, 'x')
|
||||
fp.close()
|
||||
|
||||
|
||||
@ -112,7 +116,7 @@ def signin(token) :
|
||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||
hostname=hostname)
|
||||
else :
|
||||
url_inscription = BASE_URL+'invitation/'+token
|
||||
url_inscription = BASE_URL+'inscription/'+token
|
||||
resp = render_template('inscription.html',
|
||||
signin_enable=app.config['SIGNIN_ENABLE'],
|
||||
token=token, hostname=hostname, url_inscription=url_inscription)
|
||||
|
@ -5,7 +5,6 @@ import time
|
||||
import sqlite3
|
||||
import os
|
||||
from socket import gethostname
|
||||
from subprocess import run
|
||||
from flask_bcrypt import Bcrypt
|
||||
from tools.utils import email_disp, append_to_log, gen_token
|
||||
|
||||
@ -130,14 +129,15 @@ def change_passwd() :
|
||||
passwd = request.form['password']
|
||||
|
||||
if MAIL_SERVER:
|
||||
p = run( [ SETUID, 'set_mail_passwd', "'"+mailbox['Mail']+"'", "'"+passwd+"'" ] )
|
||||
mail_passwd_change = p.returncode
|
||||
cmd = SETUID+ " set_mail_passwd " + "'"+mailbox['Mail']+"' "+"'"+passwd+"'"
|
||||
mail_passwd_change = os.system(cmd)
|
||||
|
||||
if XMMP_SERVER:
|
||||
tmp = mailbox['mail'].split('@')
|
||||
p = run( [ SETUID, 'prosodyctl register', "'"+tmp[0]+"'",
|
||||
"'"+tmp[1]+"'", "'"+passwd+"'" ])
|
||||
if p.returncode != 0:
|
||||
|
||||
if XMPP_SERVER:
|
||||
tmp = mailbox['Mail'].split('@')
|
||||
cmd = SETUID+ " prosodyctl register '"+tmp[0]+"' " + "'"+tmp[1]+"' " + "'"+passwd+"'"
|
||||
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')
|
||||
|
||||
|
||||
@ -189,8 +189,9 @@ def myalias():
|
||||
aliases = alias_list + "," +alias
|
||||
else:
|
||||
aliases = alias
|
||||
p = run( [ 'set_mail_alias', "'"+mail+"'", "add", "'"+alias+"'" ] )
|
||||
if p.returncode == 0:
|
||||
cmd = SETUID+ " set_mail_alias " + "'"+mail+"'"+" add "+"'"+alias+"'"
|
||||
res = os.system(cmd)
|
||||
if res == 0:
|
||||
cursor.execute("UPDATE users SET alias=? WHERE name=?",
|
||||
(aliases, UTILISATEUR))
|
||||
conn.commit()
|
||||
@ -245,8 +246,9 @@ def remove_alias(aliasrm):
|
||||
aliases = aliases + "," + alias
|
||||
else:
|
||||
aliases = alias
|
||||
p = run( [ 'set_mail_alias', "'"+mail+"'", "del", "'"+alias+"'" ] )
|
||||
if p.returncode == 0:
|
||||
cmd = SETUID+ " set_mail_alias " + "'"+mail+"'"+" del "+"'"+alias+"'"
|
||||
res = os.system(cmd)
|
||||
if res == 0:
|
||||
cursor.execute("UPDATE users SET alias=? WHERE name=?",
|
||||
(aliases, UTILISATEUR))
|
||||
conn.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user