|
|
@ -90,6 +90,8 @@ module.exports.statusPageSocketHandler = (socket) => {
|
|
|
|
socket.on("saveStatusPage", async (slug, config, imgDataUrl, publicGroupList, callback) => {
|
|
|
|
socket.on("saveStatusPage", async (slug, config, imgDataUrl, publicGroupList, callback) => {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
checkSlug(config.slug);
|
|
|
|
|
|
|
|
|
|
|
|
checkLogin(socket);
|
|
|
|
checkLogin(socket);
|
|
|
|
apicache.clear();
|
|
|
|
apicache.clear();
|
|
|
|
|
|
|
|
|
|
|
@ -227,11 +229,7 @@ module.exports.statusPageSocketHandler = (socket) => {
|
|
|
|
// lower case only
|
|
|
|
// lower case only
|
|
|
|
slug = slug.toLowerCase();
|
|
|
|
slug = slug.toLowerCase();
|
|
|
|
|
|
|
|
|
|
|
|
// Check slug a-z, 0-9, - only
|
|
|
|
checkSlug(slug);
|
|
|
|
// Regex from: https://stackoverflow.com/questions/22454258/js-regex-string-validation-for-slug
|
|
|
|
|
|
|
|
if (!slug.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/)) {
|
|
|
|
|
|
|
|
throw new Error("Invalid Slug");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let statusPage = R.dispense("status_page");
|
|
|
|
let statusPage = R.dispense("status_page");
|
|
|
|
statusPage.slug = slug;
|
|
|
|
statusPage.slug = slug;
|
|
|
@ -302,3 +300,23 @@ module.exports.statusPageSocketHandler = (socket) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check slug a-z, 0-9, - only
|
|
|
|
|
|
|
|
* Regex from: https://stackoverflow.com/questions/22454258/js-regex-string-validation-for-slug
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function checkSlug(slug) {
|
|
|
|
|
|
|
|
if (typeof slug !== "string") {
|
|
|
|
|
|
|
|
throw new Error("Slug must be string");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
slug = slug.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!slug) {
|
|
|
|
|
|
|
|
throw new Error("Slug cannot be empty");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!slug.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/)) {
|
|
|
|
|
|
|
|
throw new Error("Invalid Slug");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|