Skip to content

Commit

Permalink
[FIX] website_require_login: hidden exception
Browse files Browse the repository at this point in the history
  • Loading branch information
renda-dev committed Mar 20, 2024
1 parent 35d0335 commit 1963e8c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions website_require_login/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
from pathlib import Path

from psycopg2 import OperationalError

from odoo import models
from odoo.http import request

Expand All @@ -12,13 +14,19 @@ class IrHttp(models.AbstractModel):
@classmethod
def _dispatch(cls):
res = super(IrHttp, cls)._dispatch()

# if not website request - skip

website = request.env["website"].sudo().get_current_website()
if not website:
return res
if request.uid == website.user_id.id:

# if it can't access the user_id,
# it means that an exception has been
# raised and the cursor is currently closed
try:
user = website.user_id
except OperationalError:
return res

Check warning on line 28 in website_require_login/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

website_require_login/models/ir_http.py#L27-L28

Added lines #L27 - L28 were not covered by tests
if request.uid == user.id:
auth_paths = (
request.env["website.auth.url"]
.sudo()
Expand Down

0 comments on commit 1963e8c

Please sign in to comment.