diff options
| author | Xavier Morel <xmo@odoo.com> | 2019-05-13 12:31:37 +0000 |
|---|---|---|
| committer | Olivier Dony <odo@odoo.com> | 2020-08-14 21:20:47 +0000 |
| commit | 950d962d95d214bdd1bdd64d8771af96d4d618cf (patch) | |
| tree | ad71faa07eed5dd29bd9abfb41e552a20da3c363 /odoo/service | |
| parent | d21420d87ad8a269a0f30b3d9c0a3cee8c46cb14 (diff) | |
[IMP] core: add env to various auth methods
Allows accessing various keys, especially whether this is an
interactive login or not.
Also have the xml-rpc `login` delegate to `authenticate` instead of
having its own half-assed implementation.
And remove some dead code: as far as I can tell, Session.authenticate
is never called with a uid.
Diffstat (limited to 'odoo/service')
| -rw-r--r-- | odoo/service/common.py | 13 | ||||
| -rw-r--r-- | odoo/service/security.py | 7 |
2 files changed, 4 insertions, 16 deletions
diff --git a/odoo/service/common.py b/odoo/service/common.py index 42ec4ca3738..fa435c5197a 100644 --- a/odoo/service/common.py +++ b/odoo/service/common.py @@ -7,8 +7,6 @@ import odoo.tools from odoo.exceptions import AccessDenied from odoo.tools.translate import _ -from . import security - _logger = logging.getLogger(__name__) RPC_VERSION_1 = { @@ -19,17 +17,14 @@ RPC_VERSION_1 = { } def exp_login(db, login, password): - # TODO: legacy indirection through 'security', should use directly - # the res.users model - res = security.login(db, login, password) - msg = res and 'successful login' or 'bad login or password' - _logger.info("%s from '%s' using database '%s'", msg, login, db.lower()) - return res or False + return exp_authenticate(db, login, password, None) def exp_authenticate(db, login, password, user_agent_env): + if user_agent_env is None: + user_agent_env = {} res_users = odoo.registry(db)['res.users'] try: - return res_users.authenticate(db, login, password, user_agent_env) + return res_users.authenticate(db, login, password, {**user_agent_env, 'interactive': False}) except AccessDenied: return False diff --git a/odoo/service/security.py b/odoo/service/security.py index 703fd3687f3..23d89b6c691 100644 --- a/odoo/service/security.py +++ b/odoo/service/security.py @@ -4,13 +4,6 @@ import odoo import odoo.exceptions -def login(db, login, password): - res_users = odoo.registry(db)['res.users'] - try: - return res_users._login(db, login, password) - except odoo.exceptions.AccessDenied: - return False - def check(db, uid, passwd): res_users = odoo.registry(db)['res.users'] return res_users.check(db, uid, passwd) |
