File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 44from backend .common .security .jwt import DependsJwtAuth
55from backend .database .db import CurrentSession , CurrentSessionTransaction
66from backend .plugin .oauth2 .enums import UserSocialType
7- from backend .plugin .oauth2 .schema .user_social import GetUserSocialDetail
87from backend .plugin .oauth2 .service .user_social_service import user_social_service
98
109router = APIRouter ()
1110
1211
1312@router .get ('/me/bindings' , summary = '获取用户已绑定的社交账号' , dependencies = [DependsJwtAuth ])
14- async def get_user_bindings (db : CurrentSession , request : Request ) -> ResponseSchemaModel [GetUserSocialDetail ]:
13+ async def get_user_bindings (db : CurrentSession , request : Request ) -> ResponseSchemaModel [list [ str ] ]:
1514 bindings = await user_social_service .get_bindings (db = db , user_id = request .user .id )
1615 return response_base .success (data = bindings )
1716
1817
19- @router .get ('/me/binding/{source} ' , summary = '获取绑定授权链接' , dependencies = [DependsJwtAuth ])
18+ @router .get ('/me/binding' , summary = '获取绑定授权链接' , dependencies = [DependsJwtAuth ])
2019async def get_binding_auth_url (request : Request , source : UserSocialType ) -> ResponseSchemaModel [str ]:
21- binding_url = user_social_service .get_binding_auth_url (user_id = request .user .id , source = source )
20+ binding_url = await user_social_service .get_binding_auth_url (user_id = request .user .id , source = source )
2221 return response_base .success (data = binding_url )
2322
2423
Original file line number Diff line number Diff line change 44class UserSocialType (StrEnum ):
55 """用户社交类型"""
66
7- github = 'GitHub '
7+ github = 'Github '
88 google = 'Google'
99 linux_do = 'LinuxDo'
Original file line number Diff line number Diff line change 11import json
22import uuid
33
4- from collections .abc import Sequence
5-
64from sqlalchemy .ext .asyncio import AsyncSession
75
86from backend .common .exception import errors
97from backend .core .conf import settings
108from backend .database .redis import redis_client
119from backend .plugin .oauth2 .crud .crud_user_social import user_social_dao
1210from backend .plugin .oauth2 .enums import UserSocialType
13- from backend .plugin .oauth2 .model import UserSocial
1411from backend .plugin .oauth2 .schema .user_social import CreateUserSocialParam
1512
1613
1714class UserSocialService :
1815 @staticmethod
19- async def get_bindings (* , db : AsyncSession , user_id : int ) -> Sequence [ UserSocial ]:
16+ async def get_bindings (* , db : AsyncSession , user_id : int ) -> list [ str ]:
2017 """
2118 获取用户已绑定的社交账号
2219
2320 :param db: 数据库会话
2421 :param user_id: 用户 ID
2522 :return: 绑定列表,每个元素包含 sid、source 等信息
2623 """
27- return await user_social_dao .get_by_user_id (db , user_id )
24+ bindings = await user_social_dao .get_by_user_id (db , user_id )
25+ return [binding .source for binding in bindings ]
2826
2927 @staticmethod
3028 async def binding_with_oauth2 (
You can’t perform that action at this time.
0 commit comments