usernamePasswordLogin : function(loginURL, consumerKey, proxyURL) { Client.setClient( new forcetk.Client(consumerKey, loginURL, proxyURL)); var proxyLoginURL = proxyURL + '&url=' + escape(loginURL); var username = Config.get('userName'); var password = Config.get('password'); var consumerSecret = Config.get('consumerSecret'); if(Client.getClient().sessionId == null) { var that = this; $.post(proxyLoginURL, { grant_type:'password', client_id:consumerKey, client_secret:consumerSecret, username: username, password: password }, function(data) { that.sessionCallback(data) }, 'json'); } },
forcetkClientLogin: function(loginURL, consumerKey, callbackURL) { var proxyURL = callbackURL + 'proxy.php?mode=native'; this.client = new forcetk.Client(consumerKey, loginURL, proxyURL); if(this.client.sessionId == null) { var oauthResponse = {}; if (window.location.hash && window.location.href.indexOf('access_token') > 0) { var message = window.location.hash.substr(1); var nvps = message.split('&'); for (var nvp in nvps) { var parts = nvps[nvp].split('='); oauthResponse[parts[0]] = unescape(parts[1]); } console.log('init app'); if(oauthResponse['access_token']) {this.sessionCallback(oauthResponse);} } else { url = this.getAuthorizeUrl(loginURL, Config.get('consumerKey'), Config.get('callbackURL')); window.location.href = url; } } },
fixedLogin : function(){ console.log("fixedlogin"); var proxyURL = Config.get('callbackURL') + 'proxy.php?mode=native'; this.usernamePasswordLogin( this.loginURL + 'services/oauth2/token', Config.get('consumerKey'), proxyURL); }
dynamicLogin: function() { this.forcetkClientLogin( this.loginURL, Config.get('consumerKey'), Config.get('callbackURL')); },