Skip to content

Commit

Permalink
fix the callback interface return
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan committed Mar 14, 2024
1 parent fab1861 commit 9048576
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions backend/app/api/v1/auth/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from fastapi_oauth20 import FastAPIOAuth20, GitHubOAuth20
from starlette.responses import RedirectResponse

from app.common.response.response_code import StandardResponseCode
from app.services.github_service import github_service
from backend.app.common.response.response_schema import ResponseModel, response_base
from backend.app.core.conf import settings
Expand Down Expand Up @@ -33,6 +32,4 @@ async def login_github(
access_token = token['access_token']
user = await github_client.get_userinfo(access_token)
data = await github_service.add_with_login(request, background_tasks, user)
if not data:
return RedirectResponse(url='/', status_code=StandardResponseCode.HTTP_302)
return await response_base.success(data=user)
return await response_base.success(data=data)
3 changes: 2 additions & 1 deletion backend/app/services/github_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from app.common import jwt
from app.common.enums import LoginLogStatusType, UserSocialType
from app.common.exception.errors import AuthorizationError
from app.common.redis import redis_client
from app.core.conf import settings
from app.crud.crud_user import user_dao
Expand All @@ -23,7 +24,7 @@ async def add_with_login(request: Request, background_tasks: BackgroundTasks, us
async with async_db_session.begin() as db:
email = user['email']
if not email:
return None
raise AuthorizationError(msg='授权失败,GitHub 账户未绑定邮箱')
username = user['login']
nickname = user['name']
sys_user = await user_dao.get_by_username(db, username)
Expand Down

0 comments on commit 9048576

Please sign in to comment.