-add baron can change password of users

This commit is contained in:
Ulrich Knechtelsdorfer
2017-03-04 09:13:02 +01:00
parent fca49a0176
commit 5ec6dacd4b
2 changed files with 7 additions and 3 deletions

View File

@@ -14,6 +14,7 @@
Name:<br><input type="text" name="longname" required value="{{user_to_edit.longname}}" /><br>
Email:<br><input type="email" name="email" required value="{{user_to_edit.email}}" /><br>
Euml ID: (falls mehrere durch ; trennen)<br><input type="text" name="rfid_id" value="{{user_to_edit.rfid_id}}" /><br>
Neues Passwort: (wenn nicht ausgefüllt bleibt das alte)<br><input type="password" name="new_password" value="" /><br>
Geschwärzt: <input type="checkbox" name="isblack" {% if user_to_edit.isblack %} checked {% endif %} /> <br>
Baron: <input type="checkbox" name="isbaron" {% if user_to_edit.isbaron %} checked {% endif %} /> <br>
Angezeigt: <input type="checkbox" name="isshown" {% if user_to_edit.isshown %} checked {% endif %} /><br>

View File

@@ -134,6 +134,12 @@ def manage_users_edit(name=None):
u.email = request.form['email']
u.rfid_id = request.form['rfid_id']
if len(request.form['new_password']) > 0:
u.password = bcrypt.hashpw(request.form['new_password'], bcrypt.gensalt())
else:
u2 = get_user_by_id(u.id)
u.password = u2.password
if 'isblack' in request.form:
u.isblack = True
else:
@@ -159,9 +165,6 @@ def manage_users_edit(name=None):
else:
u.onlyrfid = False
u2 = get_user_by_id(u.id)
u.password = u2.password
update_user(u)
return redirect('/manage_users')