added auth collection specific check in the replacer
This commit is contained in:
File diff suppressed because one or more lines are too long
2
ui/dist/index.html
vendored
2
ui/dist/index.html
vendored
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<!-- prism -->
|
<!-- prism -->
|
||||||
<script src="./libs/prism/prism.js" data-manual></script>
|
<script src="./libs/prism/prism.js" data-manual></script>
|
||||||
<script type="module" crossorigin src="./assets/index-76OUFdvu.js"></script>
|
<script type="module" crossorigin src="./assets/index-22f_c49D.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="./assets/pocketbase.es-B_4DUNUU.js">
|
<link rel="modulepreload" crossorigin href="./assets/pocketbase.es-B_4DUNUU.js">
|
||||||
<link rel="stylesheet" crossorigin href="./assets/index-ouas71Vg.css">
|
<link rel="stylesheet" crossorigin href="./assets/index-ouas71Vg.css">
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -43,38 +43,6 @@ window.app.modals.openRecordUpsert = function(collection, record = null, modalSe
|
|||||||
app.modals.open(modal);
|
app.modals.open(modal);
|
||||||
};
|
};
|
||||||
|
|
||||||
// redact common sensitive fields
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter
|
|
||||||
function redactedReplacer(key, val) {
|
|
||||||
switch (key) {
|
|
||||||
case "expand":
|
|
||||||
case "password":
|
|
||||||
case "passwordConfirm":
|
|
||||||
case "tokenKey":
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
function downloadJSON(record) {
|
|
||||||
const pojo = JSON.parse(JSON.stringify(record, redactedReplacer));
|
|
||||||
app.utils.downloadJSON(pojo, record.collectionName + "_" + record.id + ".json");
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyJSON(record) {
|
|
||||||
app.utils.copyToClipboard(JSON.stringify(record, redactedReplacer, 2));
|
|
||||||
app.toasts.success("Record copied to clipboard!");
|
|
||||||
}
|
|
||||||
|
|
||||||
function serializeRecord(record) {
|
|
||||||
if (!record) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.stringify(record, redactedReplacer);
|
|
||||||
}
|
|
||||||
|
|
||||||
const TAB_MAIN = "main";
|
const TAB_MAIN = "main";
|
||||||
const TAB_AUTH_PROVIDERS = "authProviders";
|
const TAB_AUTH_PROVIDERS = "authProviders";
|
||||||
|
|
||||||
@@ -144,6 +112,34 @@ function recordUpsertModal(collection, rawRecord, modalSettings) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// --- serialization helpers:
|
||||||
|
|
||||||
|
// redact common sensitive fields
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter
|
||||||
|
function redactedReplacer(key, val) {
|
||||||
|
switch (key) {
|
||||||
|
case "expand":
|
||||||
|
return undefined;
|
||||||
|
// exclude internal auth record sensitive fields
|
||||||
|
case "password":
|
||||||
|
case "passwordConfirm":
|
||||||
|
case "tokenKey":
|
||||||
|
return data.isAuthCollection ? undefined : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeRecord(record) {
|
||||||
|
if (!record) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.stringify(record, redactedReplacer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
// note: not a getter to avoid the microtask batching
|
// note: not a getter to avoid the microtask batching
|
||||||
function draftKey() {
|
function draftKey() {
|
||||||
return "draft_" + collection.id + "_" + (data.originalRecord?.id || "");
|
return "draft_" + collection.id + "_" + (data.originalRecord?.id || "");
|
||||||
@@ -764,7 +760,10 @@ function recordUpsertModal(collection, rawRecord, modalSettings) {
|
|||||||
className: "dropdown-item",
|
className: "dropdown-item",
|
||||||
onclick: (e) => {
|
onclick: (e) => {
|
||||||
e.target.closest(".dropdown").hidePopover();
|
e.target.closest(".dropdown").hidePopover();
|
||||||
copyJSON(data.originalRecord);
|
app.utils.copyToClipboard(
|
||||||
|
JSON.stringify(data.originalRecord, redactedReplacer, 2),
|
||||||
|
);
|
||||||
|
app.toasts.success("Record copied to clipboard!");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
t.i({ className: "ri-braces-line", ariaHidden: true }),
|
t.i({ className: "ri-braces-line", ariaHidden: true }),
|
||||||
|
|||||||
Reference in New Issue
Block a user