mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(admin): two administrators at once leave a superuser and one user per address
An administrator cannot block, delete or demote their own account, but with two superusers each could block the other at the same moment, and none was left. Changes of the panel's users (create, edit, block, unblock, delete, group edits, and a user's own profile) now run one at a time, under a claim every worker sees, and a block, delete or edit that would leave no active superuser is refused. Under that claim each change reads the user or group as saved now: the edit forms' fingerprint is compared there, a block writes only the account's Active flag, and a profile saved while an administrator blocks the account keeps the block. A user's e-mail address is one user's, case aside, so that "Lost OTP?" can mail it; two users created or edited at once each passed that check. The form checks the address again under the same claim, with the save.
This commit is contained in:
parent
ab77b198f2
commit
b65d2abaf6
9 changed files with 330 additions and 147 deletions
|
|
@ -40,6 +40,15 @@ def hosts_lock(compute=None):
|
|||
yield
|
||||
|
||||
|
||||
@contextmanager
|
||||
def users_lock():
|
||||
"""The panel's users for the block, in one transaction, while no other
|
||||
change of them runs: what a form checked before (one user per e-mail
|
||||
address, an active superuser left) is checked again as it is saved."""
|
||||
with claims.hold({claims.users_key(): Claim.EXCLUSIVE}), transaction.atomic():
|
||||
yield
|
||||
|
||||
|
||||
@contextmanager
|
||||
def user_quota_lock(user):
|
||||
"""One user's quota check and the change it allows run one at a time."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue