perf: 优化 Provider 预加载和 bcrypt 密码验证性能

- 使用 selectinload 预加载 endpoints 避免 N+1 查询
- 将 bcrypt 密码验证移至线程池执行,避免阻塞事件循环
This commit is contained in:
AAEE86
2026-01-30 10:55:30 +08:00
parent d0ecdcd8aa
commit 897ea2e7a4
2 changed files with 5 additions and 3 deletions

View File

@@ -266,7 +266,8 @@ class AuthService:
logger.warning(f"登录失败 - 该用户使用 LDAP 认证: {email}")
return None
if not user.verify_password(password):
# 在线程池中执行 bcrypt 密码验证,避免阻塞事件循环
if not await run_in_threadpool(user.verify_password, password):
logger.warning(f"登录失败 - 密码错误: {email}")
return None