Merge branch 'role' into dev

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	backend/app/services/shipping_notice/rpa_worker_heartbeat_alert.py
#	backend/app/services/voucher_check/schedule_seed.py
#	docs/features/shipping-notice/technical.md
#	docs/tec.md
#	frontend/src/features/user/views/UserProfilePage.vue
This commit is contained in:
sophie committed 2026-09-22 18:25:45 +08:00
commit bb7e0977b8
94 files changed
+4493 -388

No files matched your search

+1 -1
View File
@@ -435,7 +435,7 @@ def _build_login_payload(user: User, source: str='password', bind_status: str=No
'username': user.username,
'role': user.role,
'default_agent_id': user.default_agent_id,
'feature_permissions': user.get_feature_permissions(),
**user.client_auth_fields(),
'source': source,
'access_token': issue_local_access_token(user),
'token_type': 'Bearer',
+4 -4
View File
@@ -185,7 +185,7 @@ def home():
raise UnauthorizedError('Unauthorized')
def _load_home_payload():
if user.role == 'admin':
if user.is_platform_admin():
agent_rows = Agent.query.filter(Agent.is_active.is_(True)).all()
else:
agent_rows = [agent for agent in user.agents if agent.is_active]
@@ -213,7 +213,7 @@ def home():
'runtime_provider': registry.get('runtime_provider'),
'conversation_mode': registry.get('conversation_mode'),
})
return jsonify({'user': {'id': user.id, 'username': user.username, 'role': user.role, 'default_agent_id': user.default_agent_id, 'feature_permissions': user.get_feature_permissions(), 'language': user.language, 'theme_preference': user.theme_preference or 'system'}, 'agents': [serialize_agent_list_item(a) for a in agent_rows], 'favorite_agent_ids': favorite_ids, 'quick_questions': [{'id': q.id, 'title': q.title, 'question': q.question, 'agent_id': q.agent_id} for q in qqs], 'embedded_agents': embedded_agents, 'layout': layout})
return jsonify({'user': {'id': user.id, 'username': user.username, 'role': user.role, 'default_agent_id': user.default_agent_id, 'language': user.language, 'theme_preference': user.theme_preference or 'system', **user.client_auth_fields()}, 'agents': [serialize_agent_list_item(a) for a in agent_rows], 'favorite_agent_ids': favorite_ids, 'quick_questions': [{'id': q.id, 'title': q.title, 'question': q.question, 'agent_id': q.agent_id} for q in qqs], 'embedded_agents': embedded_agents, 'layout': layout})
try:
return _run_db_with_retry(_load_home_payload, label='user.home')
except (OperationalError, DatabaseError) as exc:
@@ -297,7 +297,7 @@ def user_profile():
if not user:
raise UnauthorizedError('Unauthorized')
if request.method == 'GET':
return jsonify({'id': user.id, 'username': user.username, 'real_name': user.real_name, 'email': user.email, 'phone_number': user.phone_number, 'employee_id': user.employee_id, 'department': user.department, 'role': user.role, 'feature_permissions': user.get_feature_permissions(), 'language': user.language, 'theme_preference': user.theme_preference or 'system'})
return jsonify({'id': user.id, 'username': user.username, 'real_name': user.real_name, 'email': user.email, 'phone_number': user.phone_number, 'employee_id': user.employee_id, 'department': user.department, 'role': user.role, 'language': user.language, 'theme_preference': user.theme_preference or 'system', **user.client_auth_fields()})
data = request.get_json() or {}
def _update_profile():
@@ -348,7 +348,7 @@ def get_agent_details(id):
agent = db.session.get(Agent, id)
if not agent:
raise NotFoundError('Not found')
if user.role != 'admin':
if not user.is_platform_admin():
has_permission = agent in user.agents
if not has_permission:
raise ForbiddenError('Access denied')