diff --git a/auth_admin_passkey_totp_mail_enforce/tests/test_login.py b/auth_admin_passkey_totp_mail_enforce/tests/test_login.py index 7f0c302edb..94d54985d3 100644 --- a/auth_admin_passkey_totp_mail_enforce/tests/test_login.py +++ b/auth_admin_passkey_totp_mail_enforce/tests/test_login.py @@ -52,7 +52,10 @@ def test_01_web_login_with_user_password_and_2fa(self): # Reset session (login page displayed) response = self.url_open("/web/session/logout") - self.assertEqual(response.request.path_url, "/web/login") + # Response url changed by module auth_logout_redirect + self.assertIn( + response.request.path_url, ["/web/login", "/web/logout_successful"] + ) # Enable passkey and set auth_admin_passkey_ignore_totp = True config["auth_admin_passkey_password"] = self.sysadmin_passkey @@ -76,7 +79,10 @@ def test_02_web_login_with_passkey_and_2fa(self): # Reset session (login page displayed) response = self.url_open("/web/session/logout") - self.assertEqual(response.request.path_url, "/web/login") + # Response url changed by module auth_logout_redirect + self.assertIn( + response.request.path_url, ["/web/login", "/web/logout_successful"] + ) # Enable passkey and set auth_admin_passkey_ignore_totp = True config["auth_admin_passkey_password"] = self.sysadmin_passkey diff --git a/auth_logout_redirect/README.rst b/auth_logout_redirect/README.rst new file mode 100644 index 0000000000..f4931b602d --- /dev/null +++ b/auth_logout_redirect/README.rst @@ -0,0 +1,108 @@ +=============== +Logout Redirect +=============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3303bcf2401ebc8059631f92c8cdefdbdea276313f93086ffeeacc571856e32a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github + :target: https://github.com/OCA/server-auth/tree/17.0/auth_logout_redirect + :alt: OCA/server-auth +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_logout_redirect + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a page displayed when users log out. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +This is useful when a method redirects log in automatically, but an +option to stay logged out is still needed. Automatic redirection is +offered in the modules auth_oauth_autologin and auth_saml. + +Configuration +============= + +No configuration is needed when this module is used. + +Usage +===== + +The changes are visible once logged out of the application. + +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* XCG SAS + +Contributors +------------ + +- XCG SAS, part of `Orbeet `__ + + - Vincent Hatakeyama vincent.hatakeyama@orbeet.io + +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. + +.. |maintainer-vincent-hatakeyama| image:: https://github.com/vincent-hatakeyama.png?size=40px + :target: https://github.com/vincent-hatakeyama + :alt: vincent-hatakeyama + +Current `maintainer `__: + +|maintainer-vincent-hatakeyama| + +This module is part of the `OCA/server-auth `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auth_logout_redirect/__init__.py b/auth_logout_redirect/__init__.py new file mode 100644 index 0000000000..9613a24bd3 --- /dev/null +++ b/auth_logout_redirect/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import controllers diff --git a/auth_logout_redirect/__manifest__.py b/auth_logout_redirect/__manifest__.py new file mode 100644 index 0000000000..eeda03e216 --- /dev/null +++ b/auth_logout_redirect/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2025 XCG SAS +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Logout Redirect", + "summary": "Redirect on logout", + "version": "17.0.1.0.0", + "development_status": "Alpha", + "category": "Tools", + "website": "https://github.com/OCA/server-auth", + "author": "XCG SAS, Odoo Community Association (OCA)", + "maintainers": ["vincent-hatakeyama"], + "license": "AGPL-3", + "application": False, + "installable": True, + "preloadable": True, + "depends": ["web"], + "data": [ + "templates/webclient.xml", + ], +} diff --git a/auth_logout_redirect/controllers/__init__.py b/auth_logout_redirect/controllers/__init__.py new file mode 100644 index 0000000000..eb0e76aafa --- /dev/null +++ b/auth_logout_redirect/controllers/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2025 XCG SAS +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import home +from . import session diff --git a/auth_logout_redirect/controllers/home.py b/auth_logout_redirect/controllers/home.py new file mode 100644 index 0000000000..b4f60796e1 --- /dev/null +++ b/auth_logout_redirect/controllers/home.py @@ -0,0 +1,15 @@ +# Copyright © 2025 XCG SAS +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import http + + +class Home(http.Controller): + @http.route( + "/web/logout_successful", type="http", auth="none", website=False, sitemap=False + ) + def logout_successful(self): + """Landing page after successful logout. + Log out user if they were still logged in.""" + if http.request.session.uid: + return http.request.redirect("/web/session/logout", 303) + return http.request.render("auth_logout_redirect.logout_successful") diff --git a/auth_logout_redirect/controllers/session.py b/auth_logout_redirect/controllers/session.py new file mode 100644 index 0000000000..6aa66a33db --- /dev/null +++ b/auth_logout_redirect/controllers/session.py @@ -0,0 +1,15 @@ +# Copyright © 2025 XCG SAS +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import http + +from odoo.addons.web.controllers.session import Session + + +class SessionLogout(Session): + # If it was possible the default redirect would be changed. + # That does not work when http_routing is installed or any module that would change + # logout. + @http.route("/web/session/logout", type="http", auth="none") + def logout(self, redirect="/web"): # pylint: disable=unused-argument + return super().logout("web/logout_successful") diff --git a/auth_logout_redirect/pyproject.toml b/auth_logout_redirect/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/auth_logout_redirect/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/auth_logout_redirect/readme/CONFIGURE.md b/auth_logout_redirect/readme/CONFIGURE.md new file mode 100644 index 0000000000..6b0223bd75 --- /dev/null +++ b/auth_logout_redirect/readme/CONFIGURE.md @@ -0,0 +1 @@ +No configuration is needed when this module is used. diff --git a/auth_logout_redirect/readme/CONTEXT.md b/auth_logout_redirect/readme/CONTEXT.md new file mode 100644 index 0000000000..bf892eb98e --- /dev/null +++ b/auth_logout_redirect/readme/CONTEXT.md @@ -0,0 +1,3 @@ +This is useful when a method redirects log in automatically, +but an option to stay logged out is still needed. +Automatic redirection is offered in the modules auth_oauth_autologin and auth_saml. diff --git a/auth_logout_redirect/readme/CONTRIBUTORS.md b/auth_logout_redirect/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..faf3ab5e5e --- /dev/null +++ b/auth_logout_redirect/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- XCG SAS, part of [Orbeet](https://orbeet.io/) + - Vincent Hatakeyama diff --git a/auth_logout_redirect/readme/DESCRIPTION.md b/auth_logout_redirect/readme/DESCRIPTION.md new file mode 100644 index 0000000000..0884f37d0d --- /dev/null +++ b/auth_logout_redirect/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds a page displayed when users log out. diff --git a/auth_logout_redirect/readme/USAGE.md b/auth_logout_redirect/readme/USAGE.md new file mode 100644 index 0000000000..c93ff2db8b --- /dev/null +++ b/auth_logout_redirect/readme/USAGE.md @@ -0,0 +1 @@ +The changes are visible once logged out of the application. diff --git a/auth_logout_redirect/readme/newsfragments/.gitkeep b/auth_logout_redirect/readme/newsfragments/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/auth_logout_redirect/static/description/icon.png b/auth_logout_redirect/static/description/icon.png new file mode 100644 index 0000000000..1dcc49c24f Binary files /dev/null and b/auth_logout_redirect/static/description/icon.png differ diff --git a/auth_logout_redirect/static/description/icon.svg b/auth_logout_redirect/static/description/icon.svg new file mode 100644 index 0000000000..ed6aaa04e4 --- /dev/null +++ b/auth_logout_redirect/static/description/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/auth_logout_redirect/static/description/index.html b/auth_logout_redirect/static/description/index.html new file mode 100644 index 0000000000..65da3268ff --- /dev/null +++ b/auth_logout_redirect/static/description/index.html @@ -0,0 +1,451 @@ + + + + + +Logout Redirect + + + +
+

Logout Redirect

+ + +

Alpha License: AGPL-3 OCA/server-auth Translate me on Weblate Try me on Runboat

+

This module adds a page displayed when users log out.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Use Cases / Context

+

This is useful when a method redirects log in automatically, but an +option to stay logged out is still needed. Automatic redirection is +offered in the modules auth_oauth_autologin and auth_saml.

+
+
+

Configuration

+

No configuration is needed when this module is used.

+
+
+

Usage

+

The changes are visible once logged out of the application.

+
+
+

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 +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • XCG SAS
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +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.

+

Current maintainer:

+

vincent-hatakeyama

+

This module is part of the OCA/server-auth project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/auth_logout_redirect/templates/webclient.xml b/auth_logout_redirect/templates/webclient.xml new file mode 100644 index 0000000000..3df15b7d2c --- /dev/null +++ b/auth_logout_redirect/templates/webclient.xml @@ -0,0 +1,58 @@ + + + + diff --git a/auth_logout_redirect/tests/__init__.py b/auth_logout_redirect/tests/__init__.py new file mode 100644 index 0000000000..4915d9c22c --- /dev/null +++ b/auth_logout_redirect/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 XCG SAS +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_logout diff --git a/auth_logout_redirect/tests/test_logout.py b/auth_logout_redirect/tests/test_logout.py new file mode 100644 index 0000000000..714dda5ba3 --- /dev/null +++ b/auth_logout_redirect/tests/test_logout.py @@ -0,0 +1,15 @@ +# Copyright © 2025 XCG SAS +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.web.tests.test_login import TestWebLoginCommon + + +class TestWebLogin(TestWebLoginCommon): + def test_web_logout(self): + self.login("internal_user", "internal_user") + res = self.url_open("/web/session/logout") + self.assertEqual(res.request.path_url, "/web/logout_successful") + + def test_web_logout_page_while_logged_in(self): + self.login("internal_user", "internal_user") + res = self.url_open("/web/logout_successful") + self.assertEqual(res.request.path_url, "/web/logout_successful")