Skip to content

Commit

Permalink
fastapi_auth_partner: update AuthPartnerResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Nov 2, 2023
1 parent e803926 commit dc61c92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions fastapi_auth_partner/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def register(
env["fastapi.auth.service"].sudo()._register_auth(endpoint.directory_id, data)
)
partner_auth._set_auth_cookie(response)
return AuthPartnerResponse.model_validate(partner_auth)
return AuthPartnerResponse.from_auth_partner(partner_auth)


@auth_router.post("/auth/login")
Expand All @@ -57,7 +57,7 @@ def login(
env["fastapi.auth.service"].sudo()._login(endpoint.directory_id, data)
)
partner_auth._set_auth_cookie(response)
return AuthPartnerResponse.model_validate(partner_auth)
return AuthPartnerResponse.from_auth_partner(partner_auth)


@auth_router.post("/auth/logout", status_code=205)
Expand Down Expand Up @@ -91,7 +91,7 @@ def set_password(
env["fastapi.auth.service"].sudo()._set_password(endpoint.directory_id, data)
)
partner_auth._set_auth_cookie(response)
return AuthPartnerResponse.model_validate(partner_auth)
return AuthPartnerResponse.from_auth_partner(partner_auth)


@auth_router.get("/auth/profile")
Expand All @@ -103,7 +103,7 @@ def profile(
partner_auth = partner.auth_partner_ids.filtered(
lambda s: s.directory_id == endpoint.sudo().directory_id
)
return AuthPartnerResponse.model_validate(partner_auth)
return AuthPartnerResponse.from_auth_partner(partner_auth)


class AuthService(models.AbstractModel):
Expand Down
7 changes: 4 additions & 3 deletions fastapi_auth_partner/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from extendable_pydantic import StrictExtendableBaseModel

from pydantic import ConfigDict


class AuthLoginInput(StrictExtendableBaseModel):
login: str
Expand All @@ -28,4 +26,7 @@ class AuthSetPasswordInput(StrictExtendableBaseModel):

class AuthPartnerResponse(StrictExtendableBaseModel):
login: str
model_config = ConfigDict(from_attributes=True)

@classmethod
def from_auth_partner(cls, odoo_rec):
return cls.model_construct(login=odoo_rec.login)

0 comments on commit dc61c92

Please sign in to comment.