diff options
| author | Quentin (OpenERP) <qdp-launchpad@openerp.com> | 2012-11-28 12:40:02 +0100 |
|---|---|---|
| committer | Quentin (OpenERP) <qdp-launchpad@openerp.com> | 2012-11-28 12:40:02 +0100 |
| commit | e037bc48e9bae5d4bb6e0ddf736c3260bebb5f20 (patch) | |
| tree | 1c11b4752558e76a76c1947943c33c3384005287 /addons/auth_oauth/static/src/js | |
| parent | 21baf8dfac5fd73c32748f15167a3c863e477a13 (diff) | |
| parent | cb32b7e76fbf59049654cbff7ad87c3bc5a881cb (diff) | |
[MERGE] trunk
bzr revid: qdp-launchpad@openerp.com-20121128114002-yk9zk24rk79v4pkd
Diffstat (limited to 'addons/auth_oauth/static/src/js')
| -rw-r--r-- | addons/auth_oauth/static/src/js/auth_oauth.js | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/addons/auth_oauth/static/src/js/auth_oauth.js b/addons/auth_oauth/static/src/js/auth_oauth.js index 2aa66877d42..c24dab3d55a 100644 --- a/addons/auth_oauth/static/src/js/auth_oauth.js +++ b/addons/auth_oauth/static/src/js/auth_oauth.js @@ -35,27 +35,33 @@ openerp.auth_oauth = function(instance) { on_oauth_sign_in: function(ev) { ev.preventDefault(); var index = $(ev.target).data('index'); - var p = this.oauth_providers[index]; - var ret = _.str.sprintf('%s//%s/auth_oauth/signin', location.protocol, location.host); + var provider = this.oauth_providers[index]; + return this.do_oauth_sign_in(provider); + }, + do_oauth_sign_in: function(provider) { + var return_url = _.str.sprintf('%s//%s/auth_oauth/signin', location.protocol, location.host); if (instance.session.debug) { - ret += '?debug'; + return_url += '?debug'; } - var dbname = self.$("form [name=db]").val(); - var state_object = { - d: dbname, - p: p.id - }; - var state = JSON.stringify(state_object); + var state = this._oauth_state(provider); var params = { response_type: 'token', - client_id: p.client_id, - redirect_uri: ret, - scope: p.scope, - state: state, + client_id: provider.client_id, + redirect_uri: return_url, + scope: provider.scope, + state: JSON.stringify(state), }; - var url = p.auth_endpoint + '?' + $.param(params); + var url = provider.auth_endpoint + '?' + $.param(params); window.location = url; }, + _oauth_state: function(provider) { + // return the state object sent back with the redirected uri + var dbname = this.$("form [name=db]").val(); + return { + d: dbname, + p: provider.id, + }; + }, }); }; |
