From 6a82e64e4d119f3aecaa21bc39b70e46723f0f45 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 21 Jun 2013 15:23:39 +0200 Subject: [PATCH] small improvement, useful in some cases bzr revid: nicolas.vanhoren@openerp.com-20130621132339-ohk9wiufk1l9z61v --- addons/web/http.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/web/http.py b/addons/web/http.py index 4566d45eed4..c5f542d8f78 100644 --- a/addons/web/http.py +++ b/addons/web/http.py @@ -34,6 +34,7 @@ import werkzeug.routing as routing import urllib2 import openerp +import openerp.service.security as security import inspect import functools @@ -650,12 +651,17 @@ class OpenERPSession(object): self.context = {} self.jsonp_requests = {} # FIXME use a LRU - def authenticate(self, db, login, password, env=None): + def authenticate(self, db, login=None, password=None, env=None, uid=None): """ Authenticate the current user with the given db, login and password. If successful, store the authentication parameters in the current session and request. + + :param uid: If not None, that user id will be used instead the login to authenticate the user. """ - uid = openerp.netsvc.dispatch_rpc('common', 'authenticate', [db, login, password, env]) + if uid is None: + uid = openerp.netsvc.dispatch_rpc('common', 'authenticate', [db, login, password, env]) + else: + security.check(db, uid, password) self._db = db self._uid = uid self._login = login @@ -674,7 +680,6 @@ class OpenERPSession(object): """ if not self._db or not self._uid: raise SessionExpiredException("Session expired") - import openerp.service.security as security security.check(self._db, self._uid, self._password) def get_context(self):