Skip to content

Commit b415d6c

Browse files
committed
Merge PR #742 into 17.0
Signed-off-by pedrobaeza
2 parents 6b1eb73 + 7abc6d4 commit b415d6c

20 files changed

+1057
-0
lines changed

auth_oauth_multi_token/README.rst

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
=================
2+
OAuth Multi Token
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:5d69848be1a2005788b0912d52d59e788ed05ce24855822272fcdb20489ad6cc
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
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_oauth_multi_token
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_oauth_multi_token
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 the possibility to connect with the same account on
32+
more than one device at the same time.
33+
34+
All providers are supported (Google, Facebook, Odoo, etc).
35+
36+
**Table of contents**
37+
38+
.. contents::
39+
:local:
40+
41+
Usage
42+
=====
43+
44+
Nothing changes on login action: just select your provider and try to
45+
log in.
46+
47+
Bug Tracker
48+
===========
49+
50+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
51+
In case of trouble, please check there if your issue has already been reported.
52+
If you spotted it first, help us to smash it by providing a detailed and welcomed
53+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_oauth_multi_token%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
54+
55+
Do not contact contributors directly about support or help with technical issues.
56+
57+
Credits
58+
=======
59+
60+
Authors
61+
-------
62+
63+
* Florent de Labarre
64+
* Camptocamp
65+
66+
Contributors
67+
------------
68+
69+
- Florent de Labarre <florent.mirieu@gmail.com>
70+
- Simone Orsi <simone.orsi@camptocamp.com>
71+
- `Tecnativa <https://www.tecnativa.com/>`__:
72+
73+
- Jairo Llopis
74+
- Sergio Teruel
75+
76+
- Stéphane Bidoul <stephane.bidoul@acsone.eu>
77+
- Dan Tillinghast
78+
- Miku Laitinen
79+
- `Kencove <https://www.kencove.com/>`__:
80+
81+
- Mohamed Alkobrosli
82+
83+
Maintainers
84+
-----------
85+
86+
This module is maintained by the OCA.
87+
88+
.. image:: https://odoo-community.org/logo.png
89+
:alt: Odoo Community Association
90+
:target: https://odoo-community.org
91+
92+
OCA, or the Odoo Community Association, is a nonprofit organization whose
93+
mission is to support the collaborative development of Odoo features and
94+
promote its widespread use.
95+
96+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/auth_oauth_multi_token>`_ project on GitHub.
97+
98+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

auth_oauth_multi_token/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2016 Florent de Labarre
2+
# Copyright 2017 Camptocamp
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
4+
5+
{
6+
"name": "OAuth Multi Token",
7+
"version": "17.0.1.0.0",
8+
"license": "AGPL-3",
9+
"author": "Florent de Labarre, Camptocamp, Odoo Community Association (OCA)",
10+
"summary": """Allow multiple connection with the same OAuth account""",
11+
"category": "Tool",
12+
"website": "https://github.com/OCA/server-auth",
13+
"depends": ["auth_oauth"],
14+
"data": [
15+
"security/ir.model.access.csv",
16+
"views/auth_oauth_multi_token.xml",
17+
"views/res_users.xml",
18+
],
19+
"installable": True,
20+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * auth_oauth_multi_token
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 17.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: auth_oauth_multi_token
17+
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
18+
msgid "Clear Tokens"
19+
msgstr ""
20+
21+
#. module: auth_oauth_multi_token
22+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_uid
23+
msgid "Created by"
24+
msgstr ""
25+
26+
#. module: auth_oauth_multi_token
27+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_date
28+
msgid "Created on"
29+
msgstr ""
30+
31+
#. module: auth_oauth_multi_token
32+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__display_name
33+
msgid "Display Name"
34+
msgstr ""
35+
36+
#. module: auth_oauth_multi_token
37+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__id
38+
msgid "ID"
39+
msgstr ""
40+
41+
#. module: auth_oauth_multi_token
42+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token____last_update
43+
msgid "Last Modified on"
44+
msgstr ""
45+
46+
#. module: auth_oauth_multi_token
47+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_uid
48+
msgid "Last Updated by"
49+
msgstr ""
50+
51+
#. module: auth_oauth_multi_token
52+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_date
53+
msgid "Last Updated on"
54+
msgstr ""
55+
56+
#. module: auth_oauth_multi_token
57+
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
58+
msgid "Latest Tokens"
59+
msgstr ""
60+
61+
#. module: auth_oauth_multi_token
62+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_master_uuid
63+
msgid "Master UUID"
64+
msgstr ""
65+
66+
#. module: auth_oauth_multi_token
67+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_max_token
68+
msgid "Max Number of Simultaneous Connections"
69+
msgstr ""
70+
71+
#. module: auth_oauth_multi_token
72+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__oauth_access_token
73+
msgid "OAuth Access Token"
74+
msgstr ""
75+
76+
#. module: auth_oauth_multi_token
77+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_token_ids
78+
msgid "OAuth Tokens"
79+
msgstr ""
80+
81+
#. module: auth_oauth_multi_token
82+
#: model:ir.model,name:auth_oauth_multi_token.model_auth_oauth_multi_token
83+
msgid "OAuth2 Token"
84+
msgstr ""
85+
86+
#. module: auth_oauth_multi_token
87+
#: model:ir.model,name:auth_oauth_multi_token.model_res_users
88+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__user_id
89+
msgid "User"
90+
msgstr ""

auth_oauth_multi_token/i18n/it.po

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * auth_oauth_multi_token
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2024-03-14 15:38+0000\n"
10+
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
11+
"Language-Team: none\n"
12+
"Language: it\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 4.17\n"
18+
19+
#. module: auth_oauth_multi_token
20+
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
21+
msgid "Clear Tokens"
22+
msgstr "Pulisci token"
23+
24+
#. module: auth_oauth_multi_token
25+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_uid
26+
msgid "Created by"
27+
msgstr "Creato da"
28+
29+
#. module: auth_oauth_multi_token
30+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_date
31+
msgid "Created on"
32+
msgstr "Creato il"
33+
34+
#. module: auth_oauth_multi_token
35+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__display_name
36+
msgid "Display Name"
37+
msgstr "Nome visualizzato"
38+
39+
#. module: auth_oauth_multi_token
40+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__id
41+
msgid "ID"
42+
msgstr "ID"
43+
44+
#. module: auth_oauth_multi_token
45+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token____last_update
46+
msgid "Last Modified on"
47+
msgstr "Ultima modifica il"
48+
49+
#. module: auth_oauth_multi_token
50+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_uid
51+
msgid "Last Updated by"
52+
msgstr "Ultimo aggiornamento di"
53+
54+
#. module: auth_oauth_multi_token
55+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_date
56+
msgid "Last Updated on"
57+
msgstr "Ultimo aggiornamento il"
58+
59+
#. module: auth_oauth_multi_token
60+
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
61+
msgid "Latest Tokens"
62+
msgstr "Ulrimi token"
63+
64+
#. module: auth_oauth_multi_token
65+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_master_uuid
66+
msgid "Master UUID"
67+
msgstr "UUID master"
68+
69+
#. module: auth_oauth_multi_token
70+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_max_token
71+
msgid "Max Number of Simultaneous Connections"
72+
msgstr "Numero massimo di connessioni simultanee"
73+
74+
#. module: auth_oauth_multi_token
75+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__oauth_access_token
76+
msgid "OAuth Access Token"
77+
msgstr "Token accesso OAuth"
78+
79+
#. module: auth_oauth_multi_token
80+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_token_ids
81+
msgid "OAuth Tokens"
82+
msgstr "Token OAuth"
83+
84+
#. module: auth_oauth_multi_token
85+
#: model:ir.model,name:auth_oauth_multi_token.model_auth_oauth_multi_token
86+
msgid "OAuth2 Token"
87+
msgstr "Token OAuth"
88+
89+
#. module: auth_oauth_multi_token
90+
#: model:ir.model,name:auth_oauth_multi_token.model_res_users
91+
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__user_id
92+
msgid "User"
93+
msgstr "Utente"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import auth_oauth_multi_token
2+
from . import res_users
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2016 Florent de Labarre
2+
# Copyright 2017 Camptocamp
3+
# Copyright 2021 ACSONE SA/NV
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
5+
6+
from odoo import api, fields, models
7+
8+
9+
class AuthOauthMultiToken(models.Model):
10+
"""Define a set of tokens."""
11+
12+
_name = "auth.oauth.multi.token"
13+
_description = "OAuth2 Token"
14+
_order = "id desc"
15+
16+
oauth_access_token = fields.Char(
17+
string="OAuth Access Token", readonly=True, copy=False
18+
)
19+
user_id = fields.Many2one(
20+
comodel_name="res.users",
21+
string="User",
22+
required=True,
23+
readonly=True,
24+
index=True,
25+
ondelete="cascade",
26+
)
27+
28+
@api.model_create_multi
29+
def create(self, vals_list):
30+
"""Override to validate tokens."""
31+
tokens = super().create(vals_list)
32+
tokens._oauth_validate_multi_token()
33+
return tokens
34+
35+
@api.model
36+
def _oauth_user_tokens(self, user_id):
37+
"""Retrieve tokens for given user.
38+
39+
:param user_id: Odoo ID of the user
40+
"""
41+
return self.search([("user_id", "=", user_id)])
42+
43+
def _oauth_validate_multi_token(self):
44+
"""Check current user's token and clear them if max number reached."""
45+
for token in self:
46+
user_tokens = self._oauth_user_tokens(token.user_id.id)
47+
max_token = token.user_id.oauth_access_max_token
48+
if user_tokens and len(user_tokens) > max_token:
49+
# clear last token
50+
user_tokens[max_token - 1]._oauth_clear_token()
51+
52+
def _oauth_clear_token(self):
53+
"""Disable current token records."""
54+
self.unlink()

0 commit comments

Comments
 (0)