feat(permissions): 运营默认拥有微博强制更新权限

This commit is contained in:
yml
2026-11-14 14:55:42 +08:00
parent 17a2b5c464
commit f8a35ec224
3 changed files with 15 additions and 21 deletions
+13 -20
View File
@@ -309,7 +309,7 @@ def test_occupied_workbench_account_cannot_be_updated_by_another_user(db, curren
assert imported.cookie == original_cookie assert imported.cookie == original_cookie
def test_super_admin_force_updates_occupied_ck_without_changing_owner(db, current_user): def test_operator_force_updates_occupied_ck_without_changing_owner(db, current_user):
imported_out = import_cookies( imported_out = import_cookies(
WeiboCookieImport(text="SCF=a; SUB=owner"), WeiboCookieImport(text="SCF=a; SUB=owner"),
db=db, db=db,
@@ -324,6 +324,14 @@ def test_super_admin_force_updates_occupied_ck_without_changing_owner(db, curren
) )
db.add(owner) db.add(owner)
db.commit() db.commit()
operator = User(
username="weibo-force-update-operator",
password_hash="hash",
role="operation",
is_active=True,
)
db.add(operator)
db.commit()
imported.assigned_to = owner.id imported.assigned_to = owner.id
db.add( db.add(
WeiboWorkbenchAccount( WeiboWorkbenchAccount(
@@ -341,7 +349,7 @@ def test_super_admin_force_updates_occupied_ck_without_changing_owner(db, curren
force_update=True, force_update=True,
), ),
db=db, db=db,
current=current_user, current=operator,
) )
assert result.count == 1 assert result.count == 1
@@ -1153,7 +1161,7 @@ def test_weibo_batch_assign_cleans_previous_workbench(db):
assert "SCF=a" not in audit.detail assert "SCF=a" not in audit.detail
def test_weibo_force_assign_requires_dedicated_permission(db): def test_weibo_force_assign_permissions_for_operator_and_support(db):
old_support = User( old_support = User(
username="weibo-force-old-support", username="weibo-force-old-support",
password_hash="hash", password_hash="hash",
@@ -1183,17 +1191,7 @@ def test_weibo_force_assign_requires_dedicated_permission(db):
db.add(account) db.add(account)
db.commit() db.commit()
assert "weibo:assign:force" not in ROLE_PERMISSIONS["operation"] assert "weibo:assign:force" in ROLE_PERMISSIONS["operation"]
with pytest.raises(HTTPException) as exc_info:
batch_assign_accounts(
WeiboBatchAssignRequest(
account_ids=[account.id],
assigned_to=support.id,
),
db=db,
current=operator,
)
assert exc_info.value.status_code == 403
with pytest.raises(HTTPException) as exc_info: with pytest.raises(HTTPException) as exc_info:
force_assign_accounts( force_assign_accounts(
@@ -1203,15 +1201,10 @@ def test_weibo_force_assign_requires_dedicated_permission(db):
expected_count=1, expected_count=1,
), ),
db=db, db=db,
current=operator, current=support,
) )
assert exc_info.value.status_code == 403 assert exc_info.value.status_code == 403
operator.custom_permissions = [
*ROLE_PERMISSIONS["operation"],
"weibo:assign:force",
]
db.commit()
result = force_assign_accounts( result = force_assign_accounts(
WeiboForceAssignRequest( WeiboForceAssignRequest(
account_ids=[account.id], account_ids=[account.id],
+1
View File
@@ -120,6 +120,7 @@ ROLE_PERMISSIONS = {
"weibo:view", "weibo:view",
"weibo:workbench", "weibo:workbench",
"weibo:assign", "weibo:assign",
"weibo:assign:force",
"weibo:import", "weibo:import",
"weibo:manage", "weibo:manage",
"weibo:account:ck_export", "weibo:account:ck_export",
+1 -1
View File
@@ -477,7 +477,7 @@ export default function UsersPage() {
<div> <div>
<Text type="secondary"> <Text type="secondary">
打开后可查看“全部账号”页签,并把勾选账号或指定标签的账号强制转给客服。 打开后可查看“全部账号”页签,并把勾选账号或指定标签的账号强制转给客服。
该权限仅超级管理员默认拥有,运营默认关闭。 超级管理员和运营默认拥有,客服默认关闭。
</Text> </Text>
</div> </div>
</div> </div>