Skip to content

Commit

Permalink
fix(headless/socialaccount): forward authentication response
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Feb 5, 2025
1 parent 089a63a commit d3be25e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion allauth/headless/socialaccount/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def on_authentication_error(


def complete_token_login(request, sociallogin):
flows.login.complete_login(request, sociallogin, raises=True)
return flows.login.complete_login(request, sociallogin, raises=True)


def complete_login(request, sociallogin):
Expand Down
11 changes: 7 additions & 4 deletions allauth/headless/socialaccount/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ def handle(self, request, *args, **kwargs):
return super().handle(request, *args, **kwargs)

def post(self, request, *args, **kwargs):
flows.signup.signup_by_form(self.request, self.sociallogin, self.input)
return AuthenticationResponse(request)
response = flows.signup.signup_by_form(
self.request, self.sociallogin, self.input
)
return AuthenticationResponse.from_response(request, response)

def get_input_kwargs(self):
return {"sociallogin": self.sociallogin}
Expand Down Expand Up @@ -93,10 +95,11 @@ class ProviderTokenView(APIView):

def post(self, request, *args, **kwargs):
sociallogin = self.input.cleaned_data["sociallogin"]
response = None
try:
complete_token_login(request, sociallogin)
response = complete_token_login(request, sociallogin)
except ValidationError as e:
return ErrorResponse(self.request, exception=e)
except SignupClosedException:
return ForbiddenResponse(self.request)
return AuthenticationResponse(self.request)
return AuthenticationResponse.from_response(self.request, response)

0 comments on commit d3be25e

Please sign in to comment.