summaryrefslogtreecommitdiff
path: root/addons/google_account/controllers
diff options
context:
space:
mode:
authorDeep Bundela <dbu@odoo.com>2015-08-17 18:20:16 +0530
committerJérome Maes <jem@openerp.com>2016-04-27 16:35:45 +0200
commit3e1fb87e93692a11b03e1bd815a0a04d7416b4c4 (patch)
tree45df87aad86eba151d0424f5205ca14de29ff451 /addons/google_account/controllers
parent65ec248883644a0fac6ada58143bafbafd7069bc (diff)
[MIG] google_account: migrate into new API
Diffstat (limited to 'addons/google_account/controllers')
-rw-r--r--addons/google_account/controllers/main.py38
1 files changed, 17 insertions, 21 deletions
diff --git a/addons/google_account/controllers/main.py b/addons/google_account/controllers/main.py
index 504a9933fea..dd35c932a1b 100644
--- a/addons/google_account/controllers/main.py
+++ b/addons/google_account/controllers/main.py
@@ -1,32 +1,28 @@
+# -*- coding: utf-8 -*-
+
import json
-import urllib
-import openerp
-from openerp import http
-from openerp.http import request
-import openerp.addons.web.controllers.main as webmain
-from openerp.addons.web.http import SessionExpiredException
-from werkzeug.exceptions import BadRequest
-import werkzeug.utils
+from werkzeug.utils import redirect
+
+from odoo import http, registry
+from odoo.http import request
+
+
+class GoogleAuth(http.Controller):
-class google_auth(http.Controller):
-
@http.route('/google_account/authentication', type='http', auth="none")
def oauth2callback(self, **kw):
""" This route/function is called by Google when user Accept/Refuse the consent of Google """
-
+
state = json.loads(kw['state'])
dbname = state.get('d')
service = state.get('s')
url_return = state.get('f')
-
- registry = openerp.modules.registry.RegistryManager.get(dbname)
- with registry.cursor() as cr:
- if kw.get('code',False):
- registry.get('google.%s' % service).set_all_tokens(cr,request.session.uid,kw['code'])
- return werkzeug.utils.redirect(url_return)
+
+ with registry(dbname).cursor() as cr:
+ if kw.get('code'):
+ request.env(cr, request.session.uid)['google.%s' % service].set_all_tokens(kw['code'])
+ return redirect(url_return)
elif kw.get('error'):
- return werkzeug.utils.redirect("%s%s%s" % (url_return ,"?error=" , kw.get('error')))
+ return redirect("%s%s%s" % (url_return, "?error=", kw['error']))
else:
- return werkzeug.utils.redirect("%s%s" % (url_return ,"?error=Unknown_error"))
-
-
+ return redirect("%s%s" % (url_return, "?error=Unknown_error"))