Skip to content

Commit c6815f8

Browse files
committed
fix: don't send callback request if data has been modified
1 parent 90adb9e commit c6815f8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

api/views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ def parse_params(self) -> ThirdPartyAuthParamsSchema | None:
3939
# the given parameters and their signature are checked during both
4040
# POST (for obvious reasons) and GET (in order not to make
4141
# the user fill a form just to get an error he won't understand)
42-
params = self.request.GET or self.request.POST
43-
params = {key: unquote(val) for key, val in params.items()}
42+
params = self.request.GET if self.request.method == "GET" else self.request.POST
43+
params = {key: unquote(val) for key, val in params.dict().items()}
4444
try:
4545
params = ThirdPartyAuthParamsSchema(**params)
4646
except pydantic.ValidationError:
4747
messages.error(
4848
self.request, _("The data provided for authentication is incorrect")
4949
)
5050
return None
51-
client: ApiClient = get_object_or_none(ApiClient, id=params.client_id)
51+
client: ApiClient | None = get_object_or_none(ApiClient, id=params.client_id)
5252
if not client:
5353
messages.error(
5454
self.request, _("The data provided for authentication is incorrect")
@@ -71,11 +71,11 @@ def parse_params(self) -> ThirdPartyAuthParamsSchema | None:
7171
def dispatch(self, request, *args, **kwargs):
7272
if not request.user.is_authenticated:
7373
return self.handle_no_permission()
74-
self.params = self.parse_params()
75-
if not self.params:
74+
if (params := self.parse_params()) is None:
7675
# if parameters parsing failed, shortcut the operation and display
7776
# an empty page with just the error messages.
7877
return render(request, "core/base.jinja")
78+
self.params = params
7979
return super().dispatch(request, *args, **kwargs)
8080

8181
def get(self, *args, **kwargs):

0 commit comments

Comments
 (0)