summaryrefslogtreecommitdiff
path: root/odoo/http.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2019-05-13 12:31:37 +0000
committerOlivier Dony <odo@odoo.com>2020-08-14 21:20:47 +0000
commit950d962d95d214bdd1bdd64d8771af96d4d618cf (patch)
treead71faa07eed5dd29bd9abfb41e552a20da3c363 /odoo/http.py
parentd21420d87ad8a269a0f30b3d9c0a3cee8c46cb14 (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/http.py')
-rw-r--r--odoo/http.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/odoo/http.py b/odoo/http.py
index dcd36d06f81..40da5a5b131 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -974,7 +974,7 @@ class OpenERPSession(sessions.Session):
return self.__setitem__(k, v)
object.__setattr__(self, k, v)
- def authenticate(self, db, login=None, password=None, uid=None):
+ def authenticate(self, db, login=None, password=None):
"""
Authenticate the current user with the given db, login and
password. If successful, store the authentication parameters in the
@@ -984,25 +984,24 @@ class OpenERPSession(sessions.Session):
to authenticate the user.
"""
- if uid is None:
- wsgienv = request.httprequest.environ
- env = dict(
- base_location=request.httprequest.url_root.rstrip('/'),
- HTTP_HOST=wsgienv['HTTP_HOST'],
- REMOTE_ADDR=wsgienv['REMOTE_ADDR'],
- )
- uid = odoo.registry(db)['res.users'].authenticate(db, login, password, env)
- else:
- security.check(db, uid, password)
+ wsgienv = request.httprequest.environ
+ env = dict(
+ interactive=True,
+ base_location=request.httprequest.url_root.rstrip('/'),
+ HTTP_HOST=wsgienv['HTTP_HOST'],
+ REMOTE_ADDR=wsgienv['REMOTE_ADDR'],
+ )
+ uid = odoo.registry(db)['res.users'].authenticate(db, login, password, env)
+
self.rotate = True
self.db = db
self.uid = uid
self.login = login
- self.session_token = uid and security.compute_session_token(self, request.env)
+ self.session_token = security.compute_session_token(self, request.env)
request.uid = uid
request.disable_db = False
- if uid: self.get_context()
+ self.get_context()
return uid
def check_security(self):