[FIX] auth_oauth
bzr revid: fme@openerp.com-20140128085945-r5mrypiyinxs2s3h
This commit is contained in:
parent
640028b0b1
commit
35383bdc39
|
@ -33,6 +33,7 @@ Allow users to login through OAuth2 Provider.
|
||||||
'website': 'http://www.openerp.com',
|
'website': 'http://www.openerp.com',
|
||||||
'depends': ['base', 'web', 'base_setup'],
|
'depends': ['base', 'web', 'base_setup'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'res_users.xml',
|
||||||
'auth_oauth_data.xml',
|
'auth_oauth_data.xml',
|
||||||
'auth_oauth_data.yml',
|
'auth_oauth_data.yml',
|
||||||
'auth_oauth_view.xml',
|
'auth_oauth_view.xml',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import functools
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import simplejson
|
import simplejson
|
||||||
|
@ -14,6 +15,26 @@ from openerp.tools.translate import _
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
# helpers
|
||||||
|
#----------------------------------------------------------
|
||||||
|
def fragment_to_query_string(func):
|
||||||
|
@functools.wraps(func)
|
||||||
|
def wrapper(self, *a, **kw):
|
||||||
|
if not kw:
|
||||||
|
return """<html><head><script>
|
||||||
|
var l = window.location;
|
||||||
|
var q = l.hash.substring(1);
|
||||||
|
var r = '/' + l.search;
|
||||||
|
if(q.length !== 0) {
|
||||||
|
var s = l.search ? (l.search === '?' ? '' : '&') : '?';
|
||||||
|
r = l.pathname + l.search + s + q;
|
||||||
|
}
|
||||||
|
window.location = r;
|
||||||
|
</script></head><body></body></html>"""
|
||||||
|
return func(self, *a, **kw)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# Controller
|
# Controller
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
@ -73,6 +94,7 @@ class OAuthLogin(openerp.addons.web.controllers.main.Home):
|
||||||
class OAuthController(http.Controller):
|
class OAuthController(http.Controller):
|
||||||
|
|
||||||
@http.route('/auth_oauth/signin', type='http', auth='none')
|
@http.route('/auth_oauth/signin', type='http', auth='none')
|
||||||
|
@fragment_to_query_string
|
||||||
def signin(self, **kw):
|
def signin(self, **kw):
|
||||||
state = simplejson.loads(kw['state'])
|
state = simplejson.loads(kw['state'])
|
||||||
dbname = state['d']
|
dbname = state['d']
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<xpath expr="//page[@string='Access Rights']" position="after">
|
<xpath expr="//page[@string='Access Rights']" position="after">
|
||||||
<page string="Oauth">
|
<page string="Oauth">
|
||||||
<group>
|
<group>
|
||||||
<field name="oauth_provider"/>
|
<field name="oauth_provider_id"/>
|
||||||
<field name="oauth_uid"/>
|
<field name="oauth_uid"/>
|
||||||
<field name="oauth_access_token"/>
|
<field name="oauth_access_token"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
Loading…
Reference in New Issue