diff --git a/README.md b/README.md index 240be15485..4f75f44c12 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ addon | version | maintainers | summary [website_menu_by_user_status](website_menu_by_user_status/) | 16.0.1.0.0 | | Allow to manage the display of website.menus [website_odoo_debranding](website_odoo_debranding/) | 16.0.1.0.0 | | Remove Odoo Branding from Website [website_recaptcha_v2](website_recaptcha_v2/) | 16.0.1.0.0 | | Helper module to add reCAPTCHA v2 to website forms -[website_require_login](website_require_login/) | 16.0.1.0.0 | | Website Login Required +[website_require_login](website_require_login/) | 16.0.1.1.0 | | Website Login Required [website_snippet_country_dropdown](website_snippet_country_dropdown/) | 16.0.1.0.0 | | Allow to select country in a dropdown [website_snippet_country_phone_code_dropdown](website_snippet_country_phone_code_dropdown/) | 16.0.1.0.0 | | Allow to select country in a dropdown, and fill with phone code [website_whatsapp](website_whatsapp/) | 16.0.1.1.0 | ioans73 | Whatsapp integration diff --git a/website_require_login/README.rst b/website_require_login/README.rst index adcca320a6..d80b0a3a44 100644 --- a/website_require_login/README.rst +++ b/website_require_login/README.rst @@ -1,3 +1,7 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + ====================== Website Login Required ====================== @@ -7,13 +11,13 @@ Website Login Required !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:a0f16f0655f6b5b9eec2c2e621f35dbcc40c69a3c5353dec8b07ddfab1874313 + !! source digest: sha256:50ec316366ae74a190b9f995e37c1980f4efeb23be66e939b5b1c1358aa7f4bc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github diff --git a/website_require_login/__manifest__.py b/website_require_login/__manifest__.py index b93f320c18..b7594b73dc 100644 --- a/website_require_login/__manifest__.py +++ b/website_require_login/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Website Login Required", "category": "Website", - "version": "16.0.1.0.0", + "version": "16.0.1.1.0", "author": "Advitus MB, Ooops, Odoo Community Association (OCA)", "website": "https://github.com/OCA/website", "license": "LGPL-3", diff --git a/website_require_login/models/ir_http.py b/website_require_login/models/ir_http.py index bcfea63b96..5b2d92786b 100644 --- a/website_require_login/models/ir_http.py +++ b/website_require_login/models/ir_http.py @@ -44,5 +44,7 @@ def _check_require_auth(cls): path = request.httprequest.path for auth_path in auth_paths: if auth_path == path or Path(auth_path) in Path(path).parents: + if request.httprequest.content_type == "application/json": + return False redirect_path = "/web/login?redirect=%s" % path return request.redirect(redirect_path, code=302) diff --git a/website_require_login/static/description/index.html b/website_require_login/static/description/index.html index 3d6268bacf..d80b402af7 100644 --- a/website_require_login/static/description/index.html +++ b/website_require_login/static/description/index.html @@ -1,18 +1,18 @@ - -Website Login Required +README.rst -
-

Website Login Required

+
+ + +Odoo Community Association + +
+

Website Login Required

-

Beta License: LGPL-3 OCA/website Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/website Translate me on Weblate Try me on Runboat

This module allows to restrict access to specific website pages to logged users.

Table of contents

@@ -385,12 +390,12 @@

Website Login Required

-

Usage

+

Usage

Website > Configuration > Authorization required URLs: select a website and enter a relative path, eg: /shop

When public user will try to access mywebsite.com/shop or any of its child pages, they will be requested to login.

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -398,24 +403,26 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Advitus MB
  • Ooops
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

@@ -424,5 +431,6 @@

Maintainers

+
diff --git a/website_require_login/tests/test_ir_http.py b/website_require_login/tests/test_ir_http.py index ed172189b4..cf79ae5e98 100644 --- a/website_require_login/tests/test_ir_http.py +++ b/website_require_login/tests/test_ir_http.py @@ -1,3 +1,5 @@ +import json + from odoo.tests import HttpCase @@ -35,3 +37,18 @@ def test_dispatch_authorized(self): 200, "Expected the response status code to be 200 which means no redirection", ) + + def test_dispatch_json_no_redirect(self): + """With Content-Type application/json there should be no redirection.""" + self.authenticate(None, None) + response = self.url_open( + self.path, + data=json.dumps({}), + headers={"Content-Type": "application/json"}, + allow_redirects=False, + ) + self.assertNotEqual( + response.status_code, + 302, + "JSON request should not redirect even if user is not logged in", + )