diff options
| author | Raphael Collet <rco@openerp.com> | 2012-11-26 09:53:34 +0100 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2012-11-26 09:53:34 +0100 |
| commit | 1455afbda3cfa6ce917a68e2ced27ea7798ab836 (patch) | |
| tree | f3f77c3dad9cad2a0c1190cfb64bb78ef4124c92 /addons/auth_oauth/static/src/js/auth_oauth.js | |
| parent | 3854441aff047bbd34af6827a2d2b1c34780dc73 (diff) | |
[IMP] auth_oauth: refactor js method on_oauth_sign_in() to enable overriding of the oauth state definition
bzr revid: rco@openerp.com-20121126085334-df4xhhcwvwe40xgj
Diffstat (limited to 'addons/auth_oauth/static/src/js/auth_oauth.js')
| -rw-r--r-- | addons/auth_oauth/static/src/js/auth_oauth.js | 31 |
1 files changed, 17 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..2c3aa86880c 100644 --- a/addons/auth_oauth/static/src/js/auth_oauth.js +++ b/addons/auth_oauth/static/src/js/auth_oauth.js @@ -35,27 +35,30 @@ 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]; + 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 = self._oauth_state(); 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 = self.$("form [name=db]").val(); + return { + d: dbname, + p: provider.id, + }; + }, }); }; |
