1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 11:46:49 +00:00

fix(accounts): migrate no longer overrides the change-password permission

SHOW_PROFILE_EDIT_PASSWORD was replaced in 2020 by the change_password
permission, settable per user or group. A post_migrate hook applied the
old setting to all users so existing installs kept their behavior, and
asked to remove the setting afterwards; but the settings template still
set it to True. Every migrate, so every upgrade, therefore granted the
permission to all users again and undid an admin's per-user or
per-group choice (with False it would have revoked it from everyone).

- Migration accounts.0008 applies the setting one last time, if a
  settings.py still has it; the post_migrate hook is gone.
- New users get the permission when they are created (any path,
  including LDAP); the admin user form ticks it and saves the admin's
  choice afterwards.
- The template no longer sets SHOW_PROFILE_EDIT_PASSWORD; a check
  (accounts.W001) asks to remove it from existing settings, and the
  README upgrade notes say so.

The test that removes the permission and runs migrate fails on the
previous code. An upgrade from master with users was simulated: the
setting is applied once, and a permission removed afterwards stays
removed through the next migrate.
This commit is contained in:
catborise 2026-10-04 20:26:53 +03:00
parent 026391907a
commit 99dabbdcec
8 changed files with 150 additions and 26 deletions

View file

@ -288,7 +288,6 @@ ALLOW_EMPTY_PASSWORD = False
NEW_USER_DEFAULT_INSTANCES = []
# Days the owners of a VM that vanished from its compute are kept, in case it comes back
INSTANCE_OWNERSHIP_RETENTION_DAYS = 30
SHOW_PROFILE_EDIT_PASSWORD = True
# OTP Config

View file

@ -35,6 +35,7 @@ ALLOWED_FOR_ANY_USER = {
"accounts:email_otp": "part of the login flow (its own issues are tracked separately)",
"accounts:logout": "logout",
"accounts:profile": "the user's own profile",
"accounts:change_password": "the user's own password; new users get the permission by default",
"accounts:ssh_key_create": "the user's own SSH keys",
"set_language": "UI language switch",
"rest_framework:login": "DRF browsable API login",