feat: a user may have more than one profile, and may do what any of them may (Marcus, 2026-11-26)
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 8m1s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m32s
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 8m1s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m32s
operators.roles holds every profile, the main one first; permissions, moves, the column order and the machine question are the sum. The operator's machine rules apply only to the moves Operador alone allows, so an Operador who is also Revisor releases any sheet (D-29 does not block, Marcus). Usuários gets "Outros perfis" chips next to the main profile. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,10 +45,10 @@ def seed_from_environment(cursor):
|
||||
'SELECT id FROM dtf_local.operators WHERE email=%s', (email,)).fetchone()
|
||||
if existing:
|
||||
# The configured account is the system's own: it stays superadmin.
|
||||
cursor.execute("UPDATE dtf_local.operators SET role='superadmin' WHERE email=%s", (email,))
|
||||
cursor.execute("UPDATE dtf_local.operators SET role='superadmin',roles=ARRAY['superadmin'] WHERE email=%s", (email,))
|
||||
return None
|
||||
cursor.execute(
|
||||
"INSERT INTO dtf_local.operators(id,email,name,password_hash,role) VALUES(%s,%s,%s,%s,'superadmin')",
|
||||
"INSERT INTO dtf_local.operators(id,email,name,password_hash,role,roles) VALUES(%s,%s,%s,%s,'superadmin',ARRAY['superadmin'])",
|
||||
(uuid4(), email, 'Operador', password_hash(password)))
|
||||
return email
|
||||
|
||||
@@ -69,8 +69,8 @@ def add(email, name='', role='admin'):
|
||||
with connect() as c:
|
||||
if c.execute('SELECT id FROM dtf_local.operators WHERE email=%s', (email,)).fetchone():
|
||||
raise SystemExit(f'{email} already exists. Use "password" or "enable".')
|
||||
c.execute('INSERT INTO dtf_local.operators(id,email,name,password_hash,role) VALUES(%s,%s,%s,%s,%s)',
|
||||
(uuid4(), email, name, password_hash(_ask_password(email)), role))
|
||||
c.execute('INSERT INTO dtf_local.operators(id,email,name,password_hash,role,roles) VALUES(%s,%s,%s,%s,%s,%s)',
|
||||
(uuid4(), email, name, password_hash(_ask_password(email)), role, [role]))
|
||||
print(f'Added {email} as {role}.')
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ def set_role(email, role):
|
||||
if role not in ROLES:
|
||||
raise SystemExit('Role must be one of: ' + ', '.join(ROLES))
|
||||
with connect() as c:
|
||||
if not c.execute('UPDATE dtf_local.operators SET role=%s WHERE email=%s RETURNING id', (role, email)).fetchone():
|
||||
if not c.execute('UPDATE dtf_local.operators SET role=%s,roles=%s WHERE email=%s RETURNING id',
|
||||
(role, [role], email)).fetchone():
|
||||
raise SystemExit(f'{email} does not exist.')
|
||||
print(f'{email} is now {role}.')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user