Skip to content

Commit

Permalink
Fix boring login API expecting a weird form/multiparam thing instead …
Browse files Browse the repository at this point in the history
…of classic JSON for credentials ...
  • Loading branch information
alexAubin committed Jul 14, 2023
1 parent e5fa7ab commit 34a2a66
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions moulinette/interfaces/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,18 @@ def login(self):
"""

if "credentials" not in request.params:
raise HTTPResponse("Missing credentials parameter", 400)
credentials = request.params["credentials"]
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)

profile = request.params.get("profile", self.actionsmap.default_authentication)
authenticator = self.actionsmap.get_authenticator(profile)

try:
Expand Down Expand Up @@ -732,7 +739,7 @@ def api18n(callback):
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)
Expand Down

0 comments on commit 34a2a66

Please sign in to comment.