feat: allow admin to update user password without viewing it

This commit is contained in:
Manuel Weiser 2024-09-02 11:14:15 +02:00
parent d7cf96978a
commit bb4f7c2d08

View File

@ -81,6 +81,11 @@ def edit_user(user_id):
return jsonify({'message': 'User not found!'}), 404 return jsonify({'message': 'User not found!'}), 404
user.username = data.get('username', user.username) user.username = data.get('username', user.username)
user.role = data.get('role', user.role) user.role = data.get('role', user.role)
# Update password if provided
if 'password' in data:
user.password = generate_password_hash(data['password'])
db.session.commit() db.session.commit()
return jsonify({'message': 'User updated!'}), 200 return jsonify({'message': 'User updated!'}), 200