Skip to content

Commit

Permalink
Merge branch 'dev' into 182-payment-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertImKr authored Oct 14, 2024
2 parents 7fcd1ff + 0896bd8 commit 13125d0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ python manage.py runserver

### 최종 검토 및 문서화

![week3](assets/images/week3.png)
![week3](assets/images/week3.png)
Binary file added assets/images/유연우.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/유원길.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/이유정.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/임홍광.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 31 additions & 4 deletions jwtauth/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging

import jwt
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
Expand Down Expand Up @@ -160,23 +159,51 @@ def post(self, request):


class GoogleLogin(SocialLoginView):
"""
사용자가 구글 로그인을 할 때 사용, 구글 로그인을 위한 소셜 로그인 뷰입니다.
사용자가 구글사이트에서 로그인을 완료하면, 사용자 정보를 받아서 회원가입 또는 로그인 처리합니다.
닉네임은 이메일 주소의 @ 앞부분을 사용하고, 비밀번호는 사용하지 않습니다.
쿠기에 리프레시 토큰과 액세스 토큰을 저장합니다.
"""

adapter_class = GoogleOAuth2Adapter
callback_url = settings.GOOGLE_CALLBACK_URL
client_class = OAuth2Client

def get_response(self):
"""
소셜 로그인 완료 후 사용자 정보 처리
"""
response = super().get_response()

user = self.user

if not User.objects.filter(email=user.email).exists():
user = User.objects.create_user(
nickname=user.email.split("@")[0],
email=user.email,
)
user.set_unusable_password()
user.save()

access_token = generate_access_token(user)
refresh_token = generate_refresh_token(user)

response = redirect(settings.LOGIN_REDIRECT_URL)
same_site = None if settings.DEBUG else "Lax"
response.set_cookie(
key="refresh_token",
value=refresh_token,
httponly=True,
secure=not settings.DEBUG,
samesite="None",
samesite=same_site,
max_age=60 * 60 * 24 * 14,
)
response.set_cookie(
key="access_token",
value=access_token,
secure=not settings.DEBUG,
samesite=same_site,
max_age=60 * 30,
)
response.data = {"access_token": access_token}

return response
23 changes: 2 additions & 21 deletions weaverse/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,36 +201,17 @@
"key": "",
},
},
"kakao": {
"SCOPE": [
"profile",
"account_email",
],
"APP": {
"client_id": os.getenv("SOCIAL_AUTH_KAKAO_CLIENT_ID"),
"secret": "",
"key": "",
},
},
}


ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False


REST_USE_JWT = True
JWT_AUTH_COOKIE = "my-app-auth"
JWT_AUTH_REFRESH_COOKIE = "my-refresh-token"

GOOGLE_CALLBACK_URL = "https://www.weaverse.site/social-login/google/"

SOCIAL_AUTH_KAKAO_KEY = os.getenv("SOCIAL_AUTH_KAKAO_KEY")
GOOGLE_CALLBACK_URL = "https://www.weaverse.site/api/social-login/google/callback/"

REDIRECT_URL = "https://www.weaverse.site"
LOGIN_REDIRECT_URL = os.getenv("LOGIN_REDIRECT_URL", "/")
SIGNUP_REDIRECT_URL = os.getenv("SIGNUP_REDIRECT_URL", "/")
LOGOUT_REDIRECT_URL = "/"

MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/"

0 comments on commit 13125d0

Please sign in to comment.