register_remote_user: Use explicit kwargs list.

This is nicer that .pop()ing specified keys - e.g. we no longer will
have to update this chunk of code whenever adding a new key to
ExternalAuthDataDict.
This commit is contained in:
Mateusz Mandera 2022-12-15 21:29:17 +01:00 committed by Tim Abbott
parent 90cc2716f0
commit af9d1a7dfb
1 changed files with 15 additions and 3 deletions

View File

@ -300,9 +300,21 @@ def register_remote_user(request: HttpRequest, result: ExternalAuthResult) -> Ht
# the request to registration.
kwargs: Dict[str, Any] = dict(result.data_dict)
# maybe_send_to_registration doesn't take these arguments, so delete them.
kwargs.pop("subdomain", None)
kwargs.pop("redirect_to", None)
kwargs.pop("is_realm_creation", None)
# These are the kwargs taken by maybe_send_to_registration. Remove anything
# else from the dict.
kwargs_to_pass = [
"email",
"full_name",
"mobile_flow_otp",
"desktop_flow_otp",
"is_signup",
"multiuse_object_key",
"full_name_validated",
]
for key in dict(kwargs):
if key not in kwargs_to_pass:
kwargs.pop(key, None)
kwargs["password_required"] = False
return maybe_send_to_registration(request, **kwargs)