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