summaryrefslogtreecommitdiff
path: root/addons/auth_openid/controllers/main.py
diff options
context:
space:
mode:
authorAtul Patel (OpenERP) <atp@tinyerp.com>2012-08-16 10:50:21 +0530
committerAtul Patel (OpenERP) <atp@tinyerp.com>2012-08-16 10:50:21 +0530
commit22a810507cc6b4e48a067b6baaf9869d72e5a38e (patch)
tree1808e0671b83dec971ae431b6ab1f09cfbfb44e8 /addons/auth_openid/controllers/main.py
parent1d2168a02ebeeb7441c9171bd9dcda8226d29cdc (diff)
parentf4f7de136921528f4b465629ff756b367ee0bba7 (diff)
[MERGE]: Merged with lp:openobject-addons
bzr revid: atp@tinyerp.com-20120816052021-igdj7knaimwg9x7z
Diffstat (limited to 'addons/auth_openid/controllers/main.py')
-rw-r--r--addons/auth_openid/controllers/main.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/addons/auth_openid/controllers/main.py b/addons/auth_openid/controllers/main.py
index dc81730daf2..eba711dae7a 100644
--- a/addons/auth_openid/controllers/main.py
+++ b/addons/auth_openid/controllers/main.py
@@ -28,6 +28,7 @@ import werkzeug.urls
import werkzeug.exceptions
from openerp.modules.registry import RegistryManager
+from openerp.addons.web.controllers.main import login_and_redirect, set_cookie_and_redirect
try:
import openerp.addons.web.common.http as openerpweb
except ImportError:
@@ -159,7 +160,7 @@ class OpenIDController(openerpweb.Controller):
def process(self, req, **kw):
session = getattr(req.session, 'openid_session', None)
if not session:
- return werkzeug.utils.redirect('/')
+ return set_cookie_and_redirect(req, '/')
oidconsumer = consumer.Consumer(session, self._store, consumer_class=GoogleAppsAwareConsumer)
@@ -168,12 +169,11 @@ class OpenIDController(openerpweb.Controller):
display_identifier = info.getDisplayIdentifier()
session['status'] = info.status
- user_id = None
if info.status == consumer.SUCCESS:
dbname = session['dbname']
- with utils.cursor(dbname) as cr:
- registry = RegistryManager.get(dbname)
+ registry = RegistryManager.get(dbname)
+ with registry.cursor() as cr:
Modules = registry.get('ir.module.module')
installed = Modules.search_count(cr, 1, ['&', ('name', '=', 'auth_openid'), ('state', '=', 'installed')]) == 1
@@ -206,10 +206,9 @@ class OpenIDController(openerpweb.Controller):
# TODO fill empty fields with the ones from sreg/ax
cr.commit()
- req.session.authenticate(dbname, login, key, {})
+ return login_and_redirect(req, dbname, login, key)
- if not user_id:
- session['message'] = 'This OpenID identifier is not associated to any active users'
+ session['message'] = 'This OpenID identifier is not associated to any active users'
elif info.status == consumer.SETUP_NEEDED:
session['message'] = info.setup_url
@@ -223,8 +222,7 @@ class OpenIDController(openerpweb.Controller):
# information in a log.
session['message'] = 'Verification failed.'
- fragment = '#loginerror' if not user_id else ''
- return werkzeug.utils.redirect('/' + fragment)
+ return set_cookie_and_redirect(req, '/#action=login&loginerror=1')
@openerpweb.jsonrequest
def status(self, req):