Skip to content

Commit 78829e4

Browse files
[ADD] auth_logout_redirect: redirect after log out
1 parent e25ccef commit 78829e4

File tree

20 files changed

+716
-2
lines changed

20 files changed

+716
-2
lines changed

auth_admin_passkey_totp_mail_enforce/tests/test_login.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def test_01_web_login_with_user_password_and_2fa(self):
5252

5353
# Reset session (login page displayed)
5454
response = self.url_open("/web/session/logout")
55-
self.assertEqual(response.request.path_url, "/web/login")
55+
# Response url changed by module auth_logout_redirect
56+
self.assertIn(
57+
response.request.path_url, ["/web/login", "/web/logout_successful"]
58+
)
5659

5760
# Enable passkey and set auth_admin_passkey_ignore_totp = True
5861
config["auth_admin_passkey_password"] = self.sysadmin_passkey
@@ -76,7 +79,10 @@ def test_02_web_login_with_passkey_and_2fa(self):
7679

7780
# Reset session (login page displayed)
7881
response = self.url_open("/web/session/logout")
79-
self.assertEqual(response.request.path_url, "/web/login")
82+
# Response url changed by module auth_logout_redirect
83+
self.assertIn(
84+
response.request.path_url, ["/web/login", "/web/logout_successful"]
85+
)
8086

8187
# Enable passkey and set auth_admin_passkey_ignore_totp = True
8288
config["auth_admin_passkey_password"] = self.sysadmin_passkey

auth_logout_redirect/README.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
===============
2+
Logout Redirect
3+
===============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:3303bcf2401ebc8059631f92c8cdefdbdea276313f93086ffeeacc571856e32a
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-auth/tree/17.0/auth_logout_redirect
21+
:alt: OCA/server-auth
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_logout_redirect
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a page displayed when users log out.
32+
33+
.. IMPORTANT::
34+
This is an alpha version, the data model and design can change at any time without warning.
35+
Only for development or testing purpose, do not use in production.
36+
`More details on development status <https://odoo-community.org/page/development-status>`_
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Use Cases / Context
44+
===================
45+
46+
This is useful when a method redirects log in automatically, but an
47+
option to stay logged out is still needed. Automatic redirection is
48+
offered in the modules auth_oauth_autologin and auth_saml.
49+
50+
Configuration
51+
=============
52+
53+
No configuration is needed when this module is used.
54+
55+
Usage
56+
=====
57+
58+
The changes are visible once logged out of the application.
59+
60+
Bug Tracker
61+
===========
62+
63+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
64+
In case of trouble, please check there if your issue has already been reported.
65+
If you spotted it first, help us to smash it by providing a detailed and welcomed
66+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_logout_redirect%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
67+
68+
Do not contact contributors directly about support or help with technical issues.
69+
70+
Credits
71+
=======
72+
73+
Authors
74+
-------
75+
76+
* XCG Consulting
77+
78+
Contributors
79+
------------
80+
81+
- XCG Consulting, part of `Orbeet <https://orbeet.io/>`__
82+
83+
- Vincent Hatakeyama [email protected]
84+
85+
Maintainers
86+
-----------
87+
88+
This module is maintained by the OCA.
89+
90+
.. image:: https://odoo-community.org/logo.png
91+
:alt: Odoo Community Association
92+
:target: https://odoo-community.org
93+
94+
OCA, or the Odoo Community Association, is a nonprofit organization whose
95+
mission is to support the collaborative development of Odoo features and
96+
promote its widespread use.
97+
98+
.. |maintainer-vincent-hatakeyama| image:: https://github.com/vincent-hatakeyama.png?size=40px
99+
:target: https://github.com/vincent-hatakeyama
100+
:alt: vincent-hatakeyama
101+
102+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
103+
104+
|maintainer-vincent-hatakeyama|
105+
106+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/auth_logout_redirect>`_ project on GitHub.
107+
108+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

auth_logout_redirect/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import controllers
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2025 XCG Consulting
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Logout Redirect",
5+
"summary": "Redirect on logout",
6+
"version": "17.0.1.0.0",
7+
"development_status": "Alpha",
8+
"category": "Tools",
9+
"website": "https://github.com/OCA/server-auth",
10+
"author": "XCG Consulting, Odoo Community Association (OCA)",
11+
"maintainers": ["vincent-hatakeyama"],
12+
"license": "AGPL-3",
13+
"application": False,
14+
"installable": True,
15+
"preloadable": True,
16+
"depends": [
17+
"web",
18+
],
19+
"data": [
20+
'views/webclient_templates.xml',
21+
],
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2025 XCG Consulting
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from . import home
5+
from . import session
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright © 2025 XCG Consulting
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import http
4+
5+
6+
class Home(http.Controller):
7+
@http.route(
8+
"/web/logout_successful", type="http", auth="none", website=False, sitemap=False
9+
)
10+
def logout_successful(self):
11+
"""Landing page after successful logout.
12+
Log out user if they were still logged in."""
13+
if http.request.session.uid:
14+
return http.request.redirect("/web/session/logout", 303)
15+
return http.request.render("auth_logout_redirect.logout_successful")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright © 2025 XCG Consulting
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import http
5+
6+
from odoo.addons.web.controllers.session import Session
7+
8+
9+
class SessionLogout(Session):
10+
# If it was possible the default redirect would be changed.
11+
# That does not work when http_routing is installed or any module that would change
12+
# logout.
13+
@http.route("/web/session/logout", type="http", auth="none")
14+
def logout(self, redirect="/web"): # pylint: disable=unused-argument
15+
return super().logout("web/logout_successful")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No configuration is needed when this module is used.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is useful when a method redirects log in automatically,
2+
but an option to stay logged out is still needed.
3+
Automatic redirection is offered in the modules auth_oauth_autologin and auth_saml.

0 commit comments

Comments
 (0)