Fix: Kassen ohne Passwort können nun wieder geöffnet werden
- Backend erkennt passwortlose Instanzen (Hash von leerem String) - Login-Formular: required entfernt, Hinweis für passwortlose Kassen - Bei leerem Feld und passwortloser Kasse wird Zugang gewährt Made-with: Cursor
This commit is contained in:
14
app.py
14
app.py
@@ -165,9 +165,21 @@ def admin(instance_id):
|
|||||||
|
|
||||||
auth_key = f'admin_auth_{instance_id}'
|
auth_key = f'admin_auth_{instance_id}'
|
||||||
|
|
||||||
|
# Check if instance has no password (empty or None)
|
||||||
|
stored_password = instance['password']
|
||||||
|
has_no_password = (
|
||||||
|
stored_password is None or
|
||||||
|
check_password_hash(stored_password, '')
|
||||||
|
)
|
||||||
|
|
||||||
# Handle Login Submission
|
# Handle Login Submission
|
||||||
if request.method == "POST" and 'admin_password' in request.form:
|
if request.method == "POST" and 'admin_password' in request.form:
|
||||||
if check_password_hash(instance['password'], request.form['admin_password']):
|
entered = request.form['admin_password']
|
||||||
|
if has_no_password and entered == '':
|
||||||
|
session[auth_key] = True
|
||||||
|
conn.close()
|
||||||
|
return redirect(url_for('admin', instance_id=instance_id))
|
||||||
|
elif not has_no_password and check_password_hash(stored_password, entered):
|
||||||
session[auth_key] = True
|
session[auth_key] = True
|
||||||
conn.close()
|
conn.close()
|
||||||
return redirect(url_for('admin', instance_id=instance_id))
|
return redirect(url_for('admin', instance_id=instance_id))
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
<form method="post" class="bg-white p-4 shadow-sm rounded">
|
<form method="post" class="bg-white p-4 shadow-sm rounded">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="admin_password">Passworteingabe erforderlich</label>
|
<label for="admin_password">Passwort (bei passwortloser Kasse leer lassen)</label>
|
||||||
<input type="password" class="form-control" name="admin_password" id="admin_password" required
|
<input type="password" class="form-control" name="admin_password" id="admin_password"
|
||||||
autofocus>
|
autofocus placeholder="Leer lassen wenn keine Kasse mit Passwort">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary w-100">Einloggen</button>
|
<button type="submit" class="btn btn-primary w-100">Einloggen</button>
|
||||||
<a href="{{ url_for('index', instance_id=instance_id) }}" class="btn btn-secondary w-100 mt-2">Zurück zur
|
<a href="{{ url_for('index', instance_id=instance_id) }}" class="btn btn-secondary w-100 mt-2">Zurück zur
|
||||||
|
|||||||
Reference in New Issue
Block a user