diff --git a/client.js b/client.js index 287bbbc0..261ff1d5 100644 --- a/client.js +++ b/client.js @@ -609,7 +609,7 @@ CloudClient.Util = (function(){ this.isContainStr = function(pStr1, pStr2){ return pStr1 && pStr2 && - pStr1.indexOf(pStr2) > 0; + pStr1.indexOf(pStr2) >= 0; }; /** diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 95079867..13f455f1 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -30,6 +30,7 @@ var CloudCommander, Github; function(){ console.timeEnd('github load'); Util.Images.hideLoad(); + init(); }); } @@ -41,19 +42,37 @@ var CloudCommander, Github; console.log(pDate); } - GithubStore.login = function(pUser, pPasswd){ + /* PUBLICK FUNCTIONS */ + GithubStore.basicLogin = function(pUser, pPasswd){ cloudcmd.Storage.Github = new Github({ username: pUser, password: pPasswd, - auth : 'oauth' + auth : 'basic' }); }; - /* PUBLICK FUNCTIONS */ - - /** - * function bind keys - */ - cloudcmd.Storage.Keys = function(){ + + GithubStore.Login = function(pToken){ + cloudcmd.Storage.Github = new Github({ + token : pToken, + auth : 'oauth' + }); + }; + + function init(){ + var lTokin = window.location.search; + if ( Util.isContainStr(lTokin, '?code=') ) + lTokin = lTokin.replace('?code=',''); + + GithubStore.Login(lTokin); + } + + cloudcmd.Auth = function(){ + window.location = + 'https://github.com/login/oauth/authorize?client_id=' + + '891c251b925e4e967fa9'; + }; + + cloudcmd.Storage.Keys = function(){ load(); };