mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-26 22:18:30 +03:00
don't require old password for users with admin role when changing passwords
This commit is contained in:
parent
ae0c1ca941
commit
918373cb69
@ -893,13 +893,9 @@ async def update_password(
|
|||||||
except DoesNotExist:
|
except DoesNotExist:
|
||||||
return JSONResponse(content={"message": "User not found"}, status_code=404)
|
return JSONResponse(content={"message": "User not found"}, status_code=404)
|
||||||
|
|
||||||
# Require old_password when:
|
# Require old_password when non-admin user is changing any password
|
||||||
# 1. Non-admin user is changing another user's password (admin only action)
|
# Admin users changing passwords do NOT need to provide the current password
|
||||||
# 2. Any user is changing their own password
|
if current_role != "admin":
|
||||||
is_changing_own_password = current_username == username
|
|
||||||
is_non_admin = current_role != "admin"
|
|
||||||
|
|
||||||
if is_changing_own_password or is_non_admin:
|
|
||||||
if not body.old_password:
|
if not body.old_password:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"message": "Current password is required"},
|
content={"message": "Current password is required"},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user