Icu 6800 api is secret data modeling (#1448)
* refactor: 💡 Add isSecret option for model attributes Move secret attribute logic to application serializer that will remove the key/value pair if the value is null or empty ✅ Closes: ICU-6800 * refactor: 💡 Add isSecret option to credential store token * Update addons/api/addon/serializers/credential.js Remove unneeded serialize method for credentials Co-authored-by: Randall Morey <randall@randallmorey.com> * refactor: 💡 add type check for serializing secret attributes Co-authored-by: Randall Morey <randall@randallmorey.com>
This commit is contained in:
1 parent
faec9aad73
commit
84077b5d8a
7 files changed
+36
-43
No files matched your search
@@ -39,6 +39,10 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
serializeAttribute(snapshot, json, key, attribute) {
|
||||
const { type, options } = attribute;
|
||||
let value = super.serializeAttribute(...arguments);
|
||||
// Remove secret attributes that are null or empty
|
||||
if (options.isSecret) {
|
||||
if (type === 'string' && !json[key]) delete json[key];
|
||||
}
|
||||
// Convert empty strings to null.
|
||||
if (type === 'string' && json[key] === '') json[key] = null;
|
||||
// Do not serialize read-only attributes.
|
||||
|
||||
Reference in new issue
Block a user