Skip to content

Commit

Permalink
fix: add token in request before call pre-create callback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaille committed Apr 9, 2024
1 parent 4059293 commit 2bf6467
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions django_google_sso/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def callback(request: HttpRequest) -> HttpResponseRedirect:
)
return HttpResponseRedirect(login_failed_url)

# Save Token in Session
if conf.GOOGLE_SSO_SAVE_ACCESS_TOKEN:
access_token = google.get_user_token()
request.session["google_sso_access_token"] = access_token

# Run Pre-Create Callback
module_path = ".".join(conf.GOOGLE_SSO_PRE_CREATE_CALLBACK.split(".")[:-1])
pre_login_fn = conf.GOOGLE_SSO_PRE_CREATE_CALLBACK.split(".")[-1]
Expand All @@ -109,11 +114,7 @@ def callback(request: HttpRequest) -> HttpResponseRedirect:
if not user or not user.is_active:
return HttpResponseRedirect(login_failed_url)

# Save Token in Session
if conf.GOOGLE_SSO_SAVE_ACCESS_TOKEN:
access_token = google.get_user_token()
request.session["google_sso_access_token"] = access_token
request.session.save()
request.session.save()

# Run Pre-Login Callback
module_path = ".".join(conf.GOOGLE_SSO_PRE_LOGIN_CALLBACK.split(".")[:-1])
Expand Down

0 comments on commit 2bf6467

Please sign in to comment.