authorization
parent
9ad44012ce
commit
73bbd79aea
|
@ -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);
|
||||
}
|
||||
);
|
||||
|
||||
};
|
|
@ -199,6 +199,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) {
|
||||
|
@ -246,12 +247,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;
|
||||
|
@ -261,11 +271,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) {
|
||||
|
@ -302,6 +313,8 @@ GameLib.System.Storage.prototype.save = function(data) {
|
|||
component : data.apiObject,
|
||||
session : this.token
|
||||
}));
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue