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

[14.0] [FIX] website_require_login: hidden exception #1036

Merged
Merged
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
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 @@
@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
Loading