mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(fastapi): only elevated users are allowed to suspend accounts
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
446a082352
commit
85ebc72e8a
5 changed files with 72 additions and 9 deletions
|
@ -51,6 +51,9 @@ class AnonymousUser:
|
|||
LangPreference = aurweb.config.get("options", "default_lang")
|
||||
Timezone = aurweb.config.get("options", "default_timezone")
|
||||
|
||||
Suspended = 0
|
||||
InactivityTS = 0
|
||||
|
||||
# A stub ssh_pub_key relationship.
|
||||
ssh_pub_key = None
|
||||
|
||||
|
|
|
@ -143,6 +143,10 @@ def process_account_form(request: Request, user: models.User, args: dict):
|
|||
if not email or not username:
|
||||
return (False, ["Missing a required field."])
|
||||
|
||||
inactive = args.get("J", False)
|
||||
if not request.user.is_elevated() and inactive != bool(user.InactivityTS):
|
||||
return (False, ["You do not have permission to suspend accounts."])
|
||||
|
||||
username_min_len = aurweb.config.getint("options", "username_min_len")
|
||||
username_max_len = aurweb.config.getint("options", "username_max_len")
|
||||
if not util.valid_username(args.get("U")):
|
||||
|
@ -528,7 +532,8 @@ async def account_edit_post(request: Request,
|
|||
user.Homepage = HP or user.Homepage
|
||||
user.IRCNick = I or user.IRCNick
|
||||
user.PGPKey = K or user.PGPKey
|
||||
user.InactivityTS = datetime.utcnow().timestamp() if J else 0
|
||||
user.Suspended = J
|
||||
user.InactivityTS = int(datetime.utcnow().timestamp()) * int(J)
|
||||
|
||||
# If we update the language, update the cookie as well.
|
||||
if L and L != user.LangPreference:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue