[FIX] website: use public user for sitemap making (up to s14)
The current user was used to generate the sitemap. So if a user with more permissions than `public user` goes on the sitemap, he could generate it (if he is the first to see it or the last generation was more than 12 hours ago (by default)) and have pages unavailables for a user with lower permission in the sitemap (until the sitemap is generated again). The issue was solved in 8.0 withd08facdcbbut was introduced back in 10.0 withfd09ddb6fbecause the `uid` argument was dropped from `generate` method on `ModelConverter`. From 10.0 up to saas-14 the fix introduced is to use a `use_public_user` key in `request.context` but in master we will keep thefd09ddb6ffix by adding uid to the `generate` method. opw-708456 note: to forward-port only up to saas-14
This commit is contained in:
@@ -168,7 +168,7 @@ class Website(Home):
|
||||
sitemaps.unlink()
|
||||
|
||||
pages = 0
|
||||
locs = request.website.sudo(user=request.website.user_id.id).enumerate_pages()
|
||||
locs = request.website.with_context(use_public_user=True).enumerate_pages()
|
||||
while True:
|
||||
values = {
|
||||
'locs': islice(locs, 0, LOC_PER_SITEMAP),
|
||||
|
||||
@@ -363,6 +363,8 @@ class ModelConverter(ir.ir_http.ModelConverter):
|
||||
|
||||
def generate(self, query=None, args=None):
|
||||
Model = request.env[self.model]
|
||||
if request.context.get('use_public_user'):
|
||||
Model = Model.sudo(request.website.user_id.id)
|
||||
domain = safe_eval(self.domain, (args or {}).copy())
|
||||
if query:
|
||||
domain.append((Model._rec_name, 'ilike', '%' + query + '%'))
|
||||
|
||||
Reference in New Issue
Block a user