-
-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UPD] Update website_require_login.pot [UPD] README.rst
- Loading branch information
1 parent
d257f55
commit a2f50d5
Showing
18 changed files
with
774 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
====================== | ||
Website Login Required | ||
====================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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 | ||
: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 | ||
:target: https://github.com/OCA/website/tree/14.0/website_require_login | ||
:alt: OCA/website | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/website-14-0/website-14-0-website_require_login | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/186/14.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to restrict access to specific website pages to logged users. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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 | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/website/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/website/issues/new?body=module:%20website_require_login%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Advitus MB | ||
* Ooops | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Ooops404 <https://ooops404.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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. | ||
|
||
This module is part of the `OCA/website <https://github.com/OCA/website/tree/14.0/website_require_login>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2020 Advitus MB | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2020 Advitus MB | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). | ||
|
||
{ | ||
"name": "Website Login Required", | ||
"category": "Website", | ||
"version": "14.0.1.0.0", | ||
"author": "Advitus MB, Ooops, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/website", | ||
"license": "LGPL-3", | ||
"depends": [ | ||
"website", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/website_auth_url.xml", | ||
"data/ir_actions.xml", | ||
"data/ir_ui_menu.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record id="action_website_auth_url" model="ir.actions.act_window"> | ||
<field name="name">Authorization required URLs</field> | ||
<field name="res_model">website.auth.url</field> | ||
<field name="view_mode">tree</field> | ||
<field name="view_id" ref="website_auth_url_tree_view" /> | ||
<field name="target">current</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<menuitem | ||
name="Authorization required URLs" | ||
id="menu_website_auth_url" | ||
action="action_website_auth_url" | ||
parent="website.menu_website_global_configuration" | ||
sequence="60" | ||
/> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * website_require_login | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: website_require_login | ||
#: model:ir.actions.act_window,name:website_require_login.action_website_auth_url | ||
#: model:ir.model,name:website_require_login.model_website_auth_url | ||
#: model:ir.ui.menu,name:website_require_login.menu_website_auth_url | ||
#: model_terms:ir.ui.view,arch_db:website_require_login.website_auth_url_tree_view | ||
msgid "Authorization required URLs" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__create_uid | ||
msgid "Created by" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__create_date | ||
msgid "Created on" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_ir_http__display_name | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model,name:website_require_login.model_ir_http | ||
msgid "HTTP Routing" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_ir_http__id | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_ir_http____last_update | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__write_uid | ||
msgid "Last Updated by" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__write_date | ||
msgid "Last Updated on" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__path | ||
msgid "Path" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,help:website_require_login.field_website_auth_url__path | ||
msgid "" | ||
"Relative URL path and subpath. Ex.: /shop will restrict /shop, " | ||
"/shop/product, etc." | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.constraint,message:website_require_login.constraint_website_auth_url_path_unique | ||
msgid "The path must be unique per website!" | ||
msgstr "" | ||
|
||
#. module: website_require_login | ||
#: model:ir.model.fields,field_description:website_require_login.field_website_auth_url__website_id | ||
msgid "Website" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2020 Advitus MB | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). | ||
|
||
from . import ir_http | ||
from . import website_auth_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2020 Advitus MB | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). | ||
from pathlib import Path | ||
|
||
from odoo import models | ||
from odoo.http import request | ||
|
||
|
||
class IrHttp(models.AbstractModel): | ||
_inherit = "ir.http" | ||
|
||
@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: | ||
auth_paths = ( | ||
request.env["website.auth.url"] | ||
.sudo() | ||
.search( | ||
[ | ||
("website_id", "=", website.id), | ||
] | ||
) | ||
.mapped("path") | ||
) | ||
path = request.httprequest.path | ||
for auth_path in auth_paths: | ||
if auth_path == path or Path(auth_path) in Path(path).parents: | ||
return request.redirect("/web/login?redirect=%s" % path) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2020 Advitus MB | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class WebsiteAuthURL(models.Model): | ||
_name = "website.auth.url" | ||
_description = "Authorization required URLs" | ||
|
||
website_id = fields.Many2one( | ||
comodel_name="website", | ||
required=True, | ||
) | ||
|
||
path = fields.Char( | ||
required=True, | ||
help=( | ||
"Relative URL path and subpath. " | ||
"Ex.: /shop will restrict /shop, /shop/product, etc." | ||
), | ||
) | ||
|
||
_sql_constraints = [ | ||
( | ||
"path_unique", | ||
"unique (website_id, path)", | ||
"The path must be unique per website!", | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Ooops404 <https://ooops404.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module allows to restrict access to specific website pages to logged users. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_website_auth_url,access_website_auth_url,model_website_auth_url,website.group_website_designer,1,1,1,1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.