epson-tm-t20iii #1

Merged
n07070 merged 34 commits from epson-tm-t20iii into master 2022-05-04 11:57:09 +02:00
Showing only changes of commit 5b28213075 - Show all commits

View File

@ -4,3 +4,36 @@ class User(object):
def __init__(self, arg):
super(User, self).__init__()
self.arg = arg
# @app.route('/login', methods=['POST','GET'])
# @limiter.limit("100 per minute", error_message=error_handler_limiter)
def login():
if request.method == 'POST':
if not session.get('logged_in'):
if request.form['username'] and request.form['password']:
# Get the json
with open('users.json') as f:
users_file = json.load(f)
for user in users_file["users"]:
if users_file["users"][user] == request.form['password']:
session['logged_in'] = True
session['user'] = request.form['username']
if not session.get('logged_in'):
flash('Mot de passe ou pseudo invalide.','danger')
return redirect(url_for('login'))
else:
return redirect(url_for('display_index_page'))
else:
flash('Incorrect logins')
return render_template('password.html')
else:
return render_template('password.html')
else:
return render_template('password.html')
@app.route("/logout")
def logout():
session['logged_in'] = False
flash('Tu est déconnecté', 'info')
return redirect(url_for('login'))