* 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>
27 lines
731 B
JavaScript
27 lines
731 B
JavaScript
import ApplicationSerializer from './application';
|
|
import { copy } from 'ember-copy';
|
|
|
|
export default class CredentialSerializer extends ApplicationSerializer {
|
|
/**
|
|
* @override
|
|
* @method serialize
|
|
* @param {Snapshot} snapshot
|
|
*/
|
|
|
|
/**
|
|
* @type {boolean}
|
|
*/
|
|
serializeScopeID = false;
|
|
|
|
|
|
normalize(typeClass, hash, ...rest) {
|
|
const normalizedHash = copy(hash, true);
|
|
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
|
|
// Remove secret fields as we don't track them after being created/updated
|
|
normalized.data.attributes.password = '';
|
|
normalized.data.attributes.private_key = '';
|
|
normalized.data.attributes.private_key_passphrase = '';
|
|
return normalized;
|
|
}
|
|
}
|