Commit b81c1cf2 authored by Sven Franck's avatar Sven Franck

added error messages for unlogged users

parent 5760f063
...@@ -733,13 +733,24 @@ ...@@ -733,13 +733,24 @@
// access storage // access storage
return jIO.util.ajax(config) return jIO.util.ajax(config)
.then(function(response) { .then(function(response) {
var parsed = util.parse(response.target.responseText),
me = parsed.me,
flux = flux || {};
if (!me) {
return {"pass": pass};
} else {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href, "url": me.href,
"xhrFields": { "xhrFields": {
"withCredentials": true "withCredentials": true
} }
}); });
}
}).then(function (answer) { }).then(function (answer) {
if (answer.pass) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
reply = util.parse(answer.target.responseText)._links.slapos_jump; reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) { for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_ticket") { if (reply[i].name === "current_ticket") {
...@@ -755,15 +766,11 @@ ...@@ -755,15 +766,11 @@
pass.config.initial_query.skip_type = true; pass.config.initial_query.skip_type = true;
pass.config.initial_query.query = query; pass.config.initial_query.query = query;
// pass hacked query back into chain // pass hacked query back into chain
if (reply.response) {
return { return {
"response": util.parse(reply.response), "response": util.parse(reply.response),
"pass": pass "pass": pass
}; };
} }
return {
"pass": pass
}
}).fail(util.error); }).fail(util.error);
} }
return (reply); return (reply);
...@@ -830,13 +837,24 @@ ...@@ -830,13 +837,24 @@
// access storage // access storage
return jIO.util.ajax(config) return jIO.util.ajax(config)
.then(function(response) { .then(function(response) {
var parsed = util.parse(response.target.responseText),
me = parsed.me,
flux = flux || {};
if (!me) {
return {"pass": pass};
} else {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href, "url": me.href,
"xhrFields": { "xhrFields": {
"withCredentials": true "withCredentials": true
} }
}); });
}
}).then(function (answer) { }).then(function (answer) {
if (answer.pass) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
reply = util.parse(answer.target.responseText)._links.slapos_jump; reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) { for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_computer") { if (reply[i].name === "current_computer") {
...@@ -851,15 +869,11 @@ ...@@ -851,15 +869,11 @@
} }
pass.config.initial_query.query = query; pass.config.initial_query.query = query;
// pass hacked query back into chain // pass hacked query back into chain
if (reply.response) {
return { return {
"response": util.parse(reply.response), "response": util.parse(reply.response),
"pass": pass "pass": pass
}; };
} }
return {
"pass": pass
}
}).fail(util.error); }).fail(util.error);
} }
return (reply); return (reply);
...@@ -885,13 +899,25 @@ ...@@ -885,13 +899,25 @@
// access storage // access storage
return jIO.util.ajax(config) return jIO.util.ajax(config)
.then(function(response) { .then(function(response) {
var parsed = util.parse(response.target.responseText),
me = parsed.me,
flux = flux || {};
if (!me) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href, "url": me.href,
"xhrFields": { "xhrFields": {
"withCredentials": true "withCredentials": true
} }
}); });
}
}).then(function (answer) { }).then(function (answer) {
if (answer.pass) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
reply = util.parse(answer.target.responseText)._links.slapos_jump; reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) { for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_invoice") { if (reply[i].name === "current_invoice") {
...@@ -906,15 +932,11 @@ ...@@ -906,15 +932,11 @@
} }
pass.config.initial_query.query = query; pass.config.initial_query.query = query;
// pass hacked query back into chain // pass hacked query back into chain
if (reply.response) {
return { return {
"response": util.parse(reply.response), "response": util.parse(reply.response),
"pass": pass "pass": pass
}; };
} }
return {
"pass": pass
}
}).fail(util.error); }).fail(util.error);
} }
return (reply); return (reply);
...@@ -940,13 +962,26 @@ ...@@ -940,13 +962,26 @@
// access storage // access storage
return jIO.util.ajax(config) return jIO.util.ajax(config)
.then(function(response) { .then(function(response) {
var parsed = util.parse(response.target.responseText),
me = parsed.me,
flux = flux || {};
if (!me) {
return {
"pass": pass
}
} else {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href, "url": me.href,
"xhrFields": { "xhrFields": {
"withCredentials": true "withCredentials": true
} }
}); });
}
}).then(function (answer) { }).then(function (answer) {
if (answer.pass) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
reply = util.parse(answer.target.responseText)._links.slapos_jump; reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) { for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_network") { if (reply[i].name === "current_network") {
...@@ -961,15 +996,11 @@ ...@@ -961,15 +996,11 @@
} }
pass.config.initial_query.query = query; pass.config.initial_query.query = query;
// pass hacked query back into chain // pass hacked query back into chain
if (reply.response) {
return { return {
"response": util.parse(reply.response), "response": util.parse(reply.response),
"pass": pass "pass": pass
}; };
} }
return {
"pass": pass
}
}).fail(util.error); }).fail(util.error);
} }
return (reply); return (reply);
...@@ -996,13 +1027,24 @@ ...@@ -996,13 +1027,24 @@
// access storage // access storage
return jIO.util.ajax(config) return jIO.util.ajax(config)
.then(function(response) { .then(function(response) {
var parsed = util.parse(response.target.responseText),
me = parsed.me,
flux = flux || {};
if (!me) {
return {"pass": pass};
} else {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href, "url": me.href,
"xhrFields": { "xhrFields": {
"withCredentials": true "withCredentials": true
} }
}); });
}
}).then(function (answer) { }).then(function (answer) {
if (answer.pass) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
reply = util.parse(answer.target.responseText)._links.slapos_jump; reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) { for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_hosting_subscription") { if (reply[i].name === "current_hosting_subscription") {
...@@ -1017,15 +1059,11 @@ ...@@ -1017,15 +1059,11 @@
} }
pass.config.initial_query.query = query; pass.config.initial_query.query = query;
// pass hacked query back into chain // pass hacked query back into chain
if (reply.response) {
return { return {
"response": util.parse(reply.response), "response": util.parse(reply.response),
"pass": pass "pass": pass
}; };
} }
return {
"pass": pass
}
}).fail(util.error); }).fail(util.error);
} }
return (reply); return (reply);
...@@ -1179,7 +1217,6 @@ ...@@ -1179,7 +1217,6 @@
// store answer in flux // store answer in flux
flux = flux || {}; flux = flux || {};
flux.cert = util.parse(answer.target.responseText); flux.cert = util.parse(answer.target.responseText);
console.log("SET")
if (id && obj.state.callback) { if (id && obj.state.callback) {
$.mobile.changePage(obj.state.callback.replace("__id__", decode ? id : window.encodeURIComponent(id))); $.mobile.changePage(obj.state.callback.replace("__id__", decode ? id : window.encodeURIComponent(id)));
} }
...@@ -6281,7 +6318,7 @@ ...@@ -6281,7 +6318,7 @@
// update info fields // update info fields
// TODO: parentNode is not a proper selector, this should be done // TODO: parentNode is not a proper selector, this should be done
// by storing info fields associated with a gadget in state and // by saving info fields associated with a gadget in state and
// updating from there! // updating from there!
app.setInfo( app.setInfo(
config.gadget.parentNode, config.gadget.parentNode,
...@@ -7129,6 +7166,10 @@ ...@@ -7129,6 +7166,10 @@
return util.error("makeContent: Missing constructor"); return util.error("makeContent: Missing constructor");
} }
// HACK ERP5
if (flux.not_logged_in) {
util.loader("", "status_dict.please_login", "lock");
}
// set data depending on auth // set data depending on auth
if (pass.no_auth || (pass.auth && pass.active_login)) { if (pass.no_auth || (pass.auth && pass.active_login)) {
data = reply.response ? util.parse(reply.response) : null; data = reply.response ? util.parse(reply.response) : null;
...@@ -7409,9 +7450,6 @@ ...@@ -7409,9 +7450,6 @@
if (store && items.length > 0) { if (store && items.length > 0) {
// show some status
util.loader("", "status_dict.storing");
// as store will also be called directly and may require field // as store will also be called directly and may require field
// definitions for validating what is being stored, we may fetch // definitions for validating what is being stored, we may fetch
// field definitions here again. When called in the setContent // field definitions here again. When called in the setContent
...@@ -7439,7 +7477,7 @@ ...@@ -7439,7 +7477,7 @@
delete answer.pass.undo_skip; delete answer.pass.undo_skip;
// if we have an answer = field definitions, the record fields // if we have an answer = field definitions, the record fields
// must be validated before storing, so we don't store a field // must be validated before saving, so we don't store a field
// that does not exist // that does not exist
} else { } else {
if (answer.response) { if (answer.response) {
...@@ -7450,6 +7488,7 @@ ...@@ -7450,6 +7488,7 @@
} }
// if we have form_data we continue // if we have form_data we continue
if (pass.form_data === undefined) { if (pass.form_data === undefined) {
util.loader("", "status_dict.saving"); util.loader("", "status_dict.saving");
// loop over item and create a JIO record // loop over item and create a JIO record
for (i = 0; i < pass.items.length; i += 1) { for (i = 0; i < pass.items.length; i += 1) {
...@@ -7489,6 +7528,7 @@ ...@@ -7489,6 +7528,7 @@
} }
} else { } else {
// do it again, Sam... // do it again, Sam...
util.loader("", "status_dict.saving");
promises[0] = jIO.util.ajax({ promises[0] = jIO.util.ajax({
"url": storage.items.dict.url, "url": storage.items.dict.url,
"type": "GET", "type": "GET",
...@@ -7497,14 +7537,23 @@ ...@@ -7497,14 +7537,23 @@
} }
}) })
.then(function(response) { .then(function(response) {
var parsed = util.parse(response.target.responseText),
me = parsed.me,
flux = flux || {};
if (!me) {
flux.not_logged_in = true;
return {"pass": pass};
} else {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href, "url": me.href,
"xhrFields": { "xhrFields": {
"withCredentials": true "withCredentials": true
} }
}); });
}
}) })
.then(function (answer) { .then(function (answer) {
if (answer.target) {
return jIO.util.ajax({ return jIO.util.ajax({
"url": util.parse(answer.target.responseText)._actions[pass.fetch].href, "url": util.parse(answer.target.responseText)._actions[pass.fetch].href,
"type": "POST", "type": "POST",
...@@ -7513,25 +7562,32 @@ ...@@ -7513,25 +7562,32 @@
"withCredentials": true "withCredentials": true
} }
}); });
}
}) })
.then(function (erp5_response) { .then(function (erp5_response) {
if (erp5_response) {
header = erp5_response.target.getResponseHeader("Location"); header = erp5_response.target.getResponseHeader("Location");
return RSVP.resolve({ return RSVP.resolve({
"status": 200, "status": 200,
"foo": "bar", "foo": "bar",
"location": header "location": header
}); });
}
}) })
.fail(util.error); .fail(util.error);
} }
return RSVP.all(promises) return RSVP.all(promises)
.then(function (response) { .then(function (response) {
if (response[0] === undefined) {
util.loader("", "status_dict.please_login", "ban-circle");
} else {
util.loader("", "status_dict.success", "check"); util.loader("", "status_dict.success", "check");
// for single item actions, allow to return a status message // for single item actions, allow to return a status message
if (response.length === 1 && reply.pass.reply) { if (response.length === 1 && reply.pass.reply) {
send_status = response[0]; send_status = response[0];
} }
}
return { return {
"response": send_status, "response": send_status,
"pass": pass "pass": pass
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
"find_out_more_details": "For additional information, please refer to the following sections:" "find_out_more_details": "For additional information, please refer to the following sections:"
}, },
"status_dict": { "status_dict": {
"please_login": "Please log into SlapOS in another tab",
"loading_set": "Loading Records", "loading_set": "Loading Records",
"loading_fields": "Loading Configuration", "loading_fields": "Loading Configuration",
"ssl_error": "Please revoke existing certificate first", "ssl_error": "Please revoke existing certificate first",
...@@ -61,7 +62,6 @@ ...@@ -61,7 +62,6 @@
"not_found": "Page not found", "not_found": "Page not found",
"uploading": "Uploading", "uploading": "Uploading",
"fetching": "Fetching Data", "fetching": "Fetching Data",
"storing": "Storing Data",
"downloading": "Downloading", "downloading": "Downloading",
"rendering": "Rendering", "rendering": "Rendering",
"saving": "Saving", "saving": "Saving",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment