don't allow editing if pad type is wrong
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
define(function () {
|
||||
var module = {};
|
||||
|
||||
module.create = function (UserList, Title, cfg) {
|
||||
module.create = function (UserList, Title, cfg, Cryptpad) {
|
||||
var exp = {};
|
||||
|
||||
exp.update = function (shjson) {
|
||||
@@ -15,6 +15,14 @@ define(function () {
|
||||
metadata = json.metadata;
|
||||
}
|
||||
if (typeof metadata === "object") {
|
||||
if (Cryptpad) {
|
||||
if (typeof(metadata.type) === 'undefined') {
|
||||
// initialize pad type by location.pathname
|
||||
metadata.type = Cryptpad.getAppType();
|
||||
}
|
||||
} else {
|
||||
console.log("Cryptpad should exist but it does not");
|
||||
}
|
||||
if (metadata.users) {
|
||||
var userData = metadata.users;
|
||||
// Update the local user data
|
||||
|
||||
@@ -139,5 +139,12 @@ define([], function () {
|
||||
return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
|
||||
};
|
||||
|
||||
Util.getAppType = function () {
|
||||
var parts = window.location.pathname.split('/')
|
||||
.filter(function (x) { return x; });
|
||||
if (!parts[0]) { return ''; }
|
||||
return parts[0];
|
||||
};
|
||||
|
||||
return Util;
|
||||
});
|
||||
|
||||
@@ -83,6 +83,7 @@ define([
|
||||
common.fetch = Util.fetch;
|
||||
common.throttle = Util.throttle;
|
||||
common.createRandomInteger = Util.createRandomInteger;
|
||||
common.getAppType = Util.getAppType;
|
||||
|
||||
// import hash utilities for export
|
||||
var createRandomHash = common.createRandomHash = Hash.createRandomHash;
|
||||
@@ -906,18 +907,12 @@ define([
|
||||
common.getPinnedUsage(todo);
|
||||
};
|
||||
|
||||
var getAppSuffix = function () {
|
||||
var parts = window.location.pathname.split('/')
|
||||
.filter(function (x) { return x; });
|
||||
|
||||
if (!parts[0]) { return ''; }
|
||||
return '_' + parts[0].toUpperCase();
|
||||
};
|
||||
|
||||
var prepareFeedback = common.prepareFeedback = function (key) {
|
||||
if (typeof(key) !== 'string') { return $.noop; }
|
||||
|
||||
var type = common.getAppType();
|
||||
return function () {
|
||||
feedback(key.toUpperCase() + getAppSuffix());
|
||||
feedback((key + (type? '_' + type: '')).toUpperCase());
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user