Skip to content

Commit

Permalink
Merge PR #1036 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Mar 20, 2024
2 parents 35d0335 + 1963e8c commit 252a02b
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
if request.uid == user.id:
auth_paths = (
request.env["website.auth.url"]
.sudo()
Expand Down

0 comments on commit 252a02b

Please sign in to comment.