Ajout fonction première connexion et correction base de donnée

This commit is contained in:
2022-08-07 17:36:20 +02:00
parent 3451259a57
commit 78227870bc
10 changed files with 135 additions and 54 deletions

View File

@@ -1,6 +1,7 @@
from flask import Blueprint, Flask, request, flash, render_template, url_for, session, redirect, abort, make_response, send_file, escape
import sqlite3
from flask_bcrypt import Bcrypt
from socket import gethostname
app = Flask( 'pywallter' )
app.config.from_pyfile('config.py')
@@ -14,6 +15,10 @@ DOSSIER_PERSO= app.config['DOSSIER_APP']
extensionimg = app.config['EXT_IMG']
DATABASE = app.config['DATABASE']
BASE_URL = app.config['BASE_URL']
MAIL_SERVER = app.config['MAIL_SERVER']
##################################################################################################
@@ -52,7 +57,22 @@ def logout():
@loginlogout.route( '/' )
def index():
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
cursor = conn.cursor() # Création de l'objet "curseur"
cursor.execute("""SELECT token passwd FROM users where name=? """, ("pywallter", ))
tmp = cursor.fetchone()
conn.close
token = tmp[0]
if 'username' in session :
return redirect(url_for('profil.profile'))
else :
return redirect(url_for('loginlogout.login', _external=True))
if token:
hostname = gethostname()
url_inscription = BASE_URL+'inscription/'+token
return render_template('inscription.html', signin_enable=app.config['SIGNIN_ENABLE'],
token=token, hostname=hostname,
url_inscription=url_inscription,
MAIL_SERVER=MAIL_SERVER)
else:
return redirect(url_for('loginlogout.login', _external=True))