summaryrefslogtreecommitdiff
path: root/addons/auth_oauth/static/src/js/auth_oauth.js
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-08-13 01:26:12 +0200
committerAntony Lesuisse <al@openerp.com>2012-08-13 01:26:12 +0200
commit7ff74cc4b118e317a8fc25a5a507b807deeafd26 (patch)
tree3bf168b0ad2e5632885c9a35bedbe5317e395f44 /addons/auth_oauth/static/src/js/auth_oauth.js
parent9e43be663b471044b847a58040d341bc4708d982 (diff)
oauth wip
bzr revid: al@openerp.com-20120812232612-9cib8w333no9hg3d
Diffstat (limited to 'addons/auth_oauth/static/src/js/auth_oauth.js')
-rw-r--r--addons/auth_oauth/static/src/js/auth_oauth.js46
1 files changed, 13 insertions, 33 deletions
diff --git a/addons/auth_oauth/static/src/js/auth_oauth.js b/addons/auth_oauth/static/src/js/auth_oauth.js
index a49d6777e7d..057865cab4e 100644
--- a/addons/auth_oauth/static/src/js/auth_oauth.js
+++ b/addons/auth_oauth/static/src/js/auth_oauth.js
@@ -1,5 +1,4 @@
openerp.auth_oauth = function(instance) {
-
var QWeb = instance.web.qweb;
instance.web.Login = instance.web.Login.extend({
@@ -8,56 +7,37 @@ openerp.auth_oauth = function(instance) {
var self = this;
self.$element.on('click', '.oe_login_oauth a', this.on_google_oauth);
},
- on_google_oauth: function(ev) {
- var url = this._oauth_url();
- window.location = url;
- },
- _oauth_url: function() {
+ oauth_url: function(state) {
var endpoint = 'https://accounts.google.com/o/oauth2/auth';
- var params = {
+ var params = {
response_type: 'token',
client_id: '108010644258-duuhmp6pu7li4tsmnqg7j9rvdeklg0ki.apps.googleusercontent.com',
redirect_uri: 'https://localhost/',
scope: 'https://www.googleapis.com/auth/userinfo.email',
- state: 'TEST',
+ state: state,
};
var url = endpoint + '?' + $.param(params);
return url;
},
- // do_warn: function(title, msg) {
- // },
- // reset_error_message: function() {
- // }
+ on_google_oauth: function(ev) {
+ var dbname = self.$("form [name=db]").val();
+ var url = this.oauth_url(dbname);
+ window.location = url;
+ },
});
instance.web.WebClient = instance.web.WebClient.extend({
start: function() {
this._super.apply(this, arguments);
- // console.log($.deparam(window.location.hash));
var params = $.deparam(window.location.hash);
if (params.hasOwnProperty('access_token')) {
- console.log(params);
- // Do login using Google User credentials
- var url = {
-
- };
+ // fix params for python marshmalling
+ params.state = params["#state"]
+ delete params["#state"]
+ var url = "/auth_oauth/signin" + '?' + $.param(params);
+ window.location = url;
}
},
- bind_hashchange: function() {
- var state = $.bbq.getState(true);
- if (state.hasOwnProperty("access_token")) {
- state.action = "login";
- $.bbq.setState(state);
- }
- this._super();
-
- },
- // on_hashchange: function(event) {
- // console.log(event);
- // this._super.apply(this, arguments);
- // },
});
};
-
-// https://accounts.google.com/o/oauth2/auth?state=%2Fprofile&redirect_uri=http%3A%2F%2Foauth2-login-demo.appspot.com%2Fcode&response_type=code&client_id=812741506391.apps.googleusercontent.com&approval_prompt=force&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile \ No newline at end of file