authorization
parent
763d6c141e
commit
b849a949e6
|
@ -423,16 +423,6 @@ GameLib.Component.prototype.saveToRemoteAPI = function() {
|
|||
|
||||
GameLib.Component.prototype.save = function(remote) {
|
||||
|
||||
var event = GameLib.Event.GET_API_URL;
|
||||
|
||||
if (remote) {
|
||||
event = GameLib.Event.GET_REMOTE_API_URL
|
||||
}
|
||||
|
||||
this.publish(
|
||||
event,
|
||||
null,
|
||||
function(data) {
|
||||
this.buildIdToObject();
|
||||
|
||||
for (var property in this.idToObject) {
|
||||
|
@ -456,17 +446,11 @@ GameLib.Component.prototype.save = function(remote) {
|
|||
this.publish(
|
||||
GameLib.Event.SAVE_COMPONENT,
|
||||
{
|
||||
apiUrl : data.apiUrl,
|
||||
apiObject : apiObject
|
||||
apiObject: apiObject,
|
||||
remote: remote
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}.bind(this),
|
||||
function(error) {
|
||||
console.error(error);
|
||||
throw new Error('Failed to get API URL: ' + error.message);
|
||||
}
|
||||
);
|
||||
|
||||
};
|
|
@ -179,6 +179,7 @@ GameLib.System.Storage.prototype.delete = function(data) {
|
|||
|
||||
xhr.setRequestHeader("Accept", "application/json");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.setRequestHeader("x-authorization", urlData.passwoid);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (this.readyState === 4) {
|
||||
|
@ -226,12 +227,21 @@ GameLib.System.Storage.prototype.delete = function(data) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 'Saves' data to baseURL
|
||||
* 'Saves' data to somewhere
|
||||
*/
|
||||
GameLib.System.Storage.prototype.save = function(data) {
|
||||
|
||||
var event = GameLib.Event.GET_API_URL;
|
||||
|
||||
if (data.remote) {
|
||||
event = GameLib.Event.GET_REMOTE_API_URL
|
||||
}
|
||||
|
||||
this.publish(
|
||||
event,
|
||||
null,
|
||||
function(urlData) {
|
||||
if (typeof XMLHttpRequest === 'undefined') {
|
||||
console.log('Implement server side save here');
|
||||
return;
|
||||
|
@ -241,11 +251,12 @@ GameLib.System.Storage.prototype.save = function(data) {
|
|||
|
||||
xhr.open(
|
||||
'POST',
|
||||
data.apiUrl + '/component/create'
|
||||
urlData.apiUrl + '/component/create'
|
||||
);
|
||||
|
||||
xhr.setRequestHeader("Accept", "application/json");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.setRequestHeader("x-authorization", urlData.passwoid);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (this.readyState === 4) {
|
||||
|
@ -282,6 +293,8 @@ GameLib.System.Storage.prototype.save = function(data) {
|
|||
component : data.apiObject,
|
||||
session : this.token
|
||||
}));
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue