Refactor and enhance OAuth2.0 implementation; update models and routes

- Refactored AdminSummaryData and AdminSummaryResponse classes for better clarity.
- Added OAUTH type to SettingsType enum.
- Cleaned up imports in webdav.py.
- Updated admin router to improve summary data retrieval and response handling.
- Enhanced file management routes with better condition handling and user storage updates.
- Improved group management routes by optimizing data retrieval.
- Refined task management routes for better condition handling.
- Updated user management routes to streamline access token retrieval.
- Implemented a new captcha verification structure with abstract base class.
- Removed deprecated env.md file and replaced with a new structured version.
- Introduced a unified OAuth2.0 client base class for GitHub and QQ integrations.
- Enhanced password management with improved hashing strategies.
- Added detailed comments and documentation throughout the codebase for clarity.
This commit is contained in:
2026-01-12 18:07:44 +08:00
parent 61ddc96f17
commit d2c914cff8
29 changed files with 814 additions and 4609 deletions

View File

@@ -42,10 +42,9 @@ class GroupFactory:
speed_limit=kwargs.get("speed_limit", 0),
)
group = await group.save(session)
# 如果提供了选项参数,创建 GroupOptions
if kwargs.get("create_options", False):
group = await group.save(session, commit=False)
options = GroupOptions(
group_id=group.id,
share_download=kwargs.get("share_download", True),
@@ -55,7 +54,10 @@ class GroupFactory:
select_node=kwargs.get("select_node", False),
advance_delete=kwargs.get("advance_delete", False),
)
await options.save(session)
await options.save(session, commit=False)
await session.commit()
else:
group = await group.save(session)
return group
@@ -88,7 +90,7 @@ class GroupFactory:
speed_limit=0,
)
admin_group = await admin_group.save(session)
admin_group = await admin_group.save(session, commit=False)
# 创建管理员组选项
admin_options = GroupOptions(
@@ -105,7 +107,8 @@ class GroupFactory:
aria2=True,
redirected_source=True,
)
await admin_options.save(session)
await admin_options.save(session, commit=False)
await session.commit()
return admin_group
@@ -140,7 +143,7 @@ class GroupFactory:
speed_limit=1024, # 1MB/s
)
limited_group = await limited_group.save(session)
limited_group = await limited_group.save(session, commit=False)
# 创建限制组选项
limited_options = GroupOptions(
@@ -152,7 +155,8 @@ class GroupFactory:
select_node=False,
advance_delete=False,
)
await limited_options.save(session)
await limited_options.save(session, commit=False)
await session.commit()
return limited_group
@@ -185,7 +189,7 @@ class GroupFactory:
speed_limit=512, # 512KB/s
)
free_group = await free_group.save(session)
free_group = await free_group.save(session, commit=False)
# 创建免费组选项
free_options = GroupOptions(
@@ -197,6 +201,7 @@ class GroupFactory:
select_node=False,
advance_delete=False,
)
await free_options.save(session)
await free_options.save(session, commit=False)
await session.commit()
return free_group