Skip to content

Commit

Permalink
[18.0][FIX] fastapi, use new authenticate signature and dict answer
Browse files Browse the repository at this point in the history
  • Loading branch information
cormaza committed Dec 11, 2024
1 parent d960109 commit 57944ca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fastapi/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ def basic_auth_user(
username = credential.username
password = credential.password
try:
uid = (
response = (

Check warning on line 117 in fastapi/dependencies.py

View check run for this annotation

Codecov / codecov/patch

fastapi/dependencies.py#L114-L117

Added lines #L114 - L117 were not covered by tests
env["res.users"]
.sudo()
.authenticate(
db=env.cr.dbname, login=username, password=password, user_agent_env=None
db=env.cr.dbname,
credential={
"type": "password",
"login": username,
"password": password,
},
user_agent_env=None,
)
)
return env["res.users"].browse(uid)
return env["res.users"].browse(response.get("uid"))
except AccessDenied as ad:
raise HTTPException(

Check warning on line 132 in fastapi/dependencies.py

View check run for this annotation

Codecov / codecov/patch

fastapi/dependencies.py#L130-L132

Added lines #L130 - L132 were not covered by tests
status_code=status.HTTP_401_UNAUTHORIZED,
Expand Down

0 comments on commit 57944ca

Please sign in to comment.