Fix boring login API expecting a weird form/multiparam thing instead of classic JSON for credentials ...

This commit is contained in:
Alexandre Aubin 2023-07-14 19:09:00 +02:00
parent e5fa7ab734
commit 34a2a66027

View file

@ -353,11 +353,18 @@ class _ActionsMapPlugin:
"""
if request.get_header("Content-Type") == "application/json":
if "credentials" not in request.json:
raise HTTPResponse("Missing credentials parameter", 400)
credentials = request.json["credentials"]
profile = request.json.get("profile", self.actionsmap.default_authentication)
else:
if "credentials" not in request.params:
raise HTTPResponse("Missing credentials parameter", 400)
credentials = request.params["credentials"]
profile = request.params.get("profile", self.actionsmap.default_authentication)
authenticator = self.actionsmap.get_authenticator(profile)
try:
@ -732,7 +739,7 @@ class Interface:
def wrapper(*args, **kwargs):
try:
locale = request.params.pop("locale")
except KeyError:
except (KeyError, ValueError):
locale = m18n.default_locale
m18n.set_locale(locale)
return callback(*args, **kwargs)