Merge branch 'dev' into runny827

feat(training): 新增精益培训视频与周任务管理

# Conflicts:
#	backend/app/models/__init__.py
This commit is contained in:
runny committed 2026-09-08 18:30:09 +08:00
1 parent 85d27e9ffa
commit 91b7233872
812 files changed
+73763 -18908

No files matched your search

+7 -1
View File
@@ -101,7 +101,7 @@ def login():
@auth_bp.post('/change-password', endpoint='change_password')
def change_password():
"""校验当前身份并同步更新本地与 Casdoor 密码。"""
"""校验当前身份并同步更新本地与 Casdoor 密码;新密码与原密码相同直接 400。"""
user = _compat._get_current_user()
if not user:
raise UnauthorizedError('Unauthorized')
@@ -110,6 +110,12 @@ def change_password():
new_password = data.get('new_password')
if not current_password or not new_password:
raise ValidationError('Current and new password are required')
if current_password == new_password:
raise AppError(
code='AUTH.PASSWORD_UNCHANGED',
message='New password must differ from the current password',
http_status=400,
)
try:
_compat._verify_current_password_for_change(user, current_password)
_compat._sync_casdoor_password(user.username, current_password, new_password)
+4 -1
View File
@@ -16,7 +16,7 @@ from app.services.agent_category import serialize_agent_list_item, sort_agent_ro
from app.services.agent_registry.serialization import serialize_registry_fields
from app.services.wecom_notify import mark_wecom_message_opened, send_wecom_event_message
from app.services.wecom_crypto import sha1_hex, decrypt_wecom_aes, extract_encrypt_field
from app.core.auth.jwt import get_current_user as _auth_current_user
from app.core.auth.jwt import get_current_user as _auth_current_user, issue_local_access_token
from sqlalchemy.exc import DatabaseError, IntegrityError, OperationalError
from sqlalchemy import and_, or_, inspect, insert
from datetime import datetime, timedelta
@@ -324,12 +324,15 @@ def _verify_current_password_for_change(user, current_password: str):
raise
def _sync_casdoor_password(username: str, current_password: str, new_password: str):
"""将用户自助改密同步到 Casdoor;新密码未变化原样抛出,原密码错误转为 403。"""
if not _is_casdoor_configured():
return
user_owner = _casdoor_user_owner()
try:
_casdoor_set_password(user_owner, username, current_password, new_password)
except AppError as first_error:
if first_error.code == 'AUTH.PASSWORD_UNCHANGED':
raise
if first_error.code in ('CASDOOR_INVALID_CREDENTIALS', 'AUTH.INCORRECT_CURRENT_PASSWORD'):
_raise_incorrect_current_password()
raise