mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
feature(config) mv apiURL to CloudFunc
This commit is contained in:
parent
b9273f9166
commit
88713a9643
6 changed files with 59 additions and 54 deletions
|
|
@ -54,6 +54,7 @@ var CloudCmd, Util, DOM, CloudFunc, Github, cb;
|
|||
GitHub.autorize = function(callback, code) {
|
||||
Storage.get('token', function(token) {
|
||||
var isContain,
|
||||
apiURL = CloudFunc.apiURL,
|
||||
URL = '//' + window.location.host + '/auth/github';
|
||||
|
||||
if (token) {
|
||||
|
|
@ -68,22 +69,20 @@ var CloudCmd, Util, DOM, CloudFunc, Github, cb;
|
|||
if (!isContain)
|
||||
DOM.openWindow(URL);
|
||||
else
|
||||
CloudCmd.getConfig(function(config) {
|
||||
DOM.ajax({
|
||||
type : 'put',
|
||||
url : config && config.apiURL + '/auth',
|
||||
data : Util.rmStr(code, '?code='),
|
||||
success : function(data) {
|
||||
if (data && data.token) {
|
||||
token = data.token;
|
||||
|
||||
GitHub.Login(token);
|
||||
Storage.set('token', token);
|
||||
Util.exec(callback);
|
||||
} else
|
||||
Util.log('Worning: token not getted...');
|
||||
}
|
||||
});
|
||||
DOM.ajax({
|
||||
type : 'put',
|
||||
url : apiURL + '/auth',
|
||||
data : Util.rmStr(code, '?code='),
|
||||
success : function(data) {
|
||||
if (data && data.token) {
|
||||
token = data.token;
|
||||
|
||||
GitHub.Login(token);
|
||||
Storage.set('token', token);
|
||||
Util.exec(callback);
|
||||
} else
|
||||
Util.log('Worning: token not getted...');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue