Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TODO] issue with public service [help needed] #1093

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shopinvader/components/service_context_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def _get_backend(self):
website_unique_key = self.request.httprequest.environ.get(
"HTTP_WEBSITE_UNIQUE_KEY"
)
return self.env["shopinvader.backend"]._get_from_website_unique_key(
website_unique_key
return (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastienbeau IMO we should never use sudo in this case... Services are run with a technical user. Therefore, the technical user should have the right to read backend information.

self.env["shopinvader.backend"]
.sudo()
._get_from_website_unique_key(website_unique_key)
)

def _get_component_context(self):
Expand Down
6 changes: 4 additions & 2 deletions shopinvader/models/shopinvader_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,13 @@ def _validate_partner(self, shopinvader_partner):
@api.model
@tools.ormcache("self._uid", "website_unique_key")
def _get_id_from_website_unique_key(self, website_unique_key):
return self.search([("website_unique_key", "=", website_unique_key)]).id
return self.sudo().search([("website_unique_key", "=", website_unique_key)]).id

@api.model
def _get_from_website_unique_key(self, website_unique_key):
return self.browse(self._get_id_from_website_unique_key(website_unique_key))
return self.sudo().browse(
self._get_id_from_website_unique_key(website_unique_key)
)

def write(self, values):
if "website_unique_key" in values:
Expand Down
2 changes: 1 addition & 1 deletion shopinvader_auth_api_key/models/shopinvader_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _get_api_key_name(cls, auth_api_key):
@api.model
@tools.ormcache("self._uid", "auth_api_key_id")
def _get_id_from_auth_api_key(self, auth_api_key_id):
return self.search([("auth_api_key_id", "=", auth_api_key_id)]).id
return self.sudo().search([("auth_api_key_id", "=", auth_api_key_id)]).id

@api.model
def _get_from_auth_api_key(self, auth_api_key_id):
Expand Down