2022-07-20 12:34:18 -07:00
|
|
|
import ApplicationSerializer from './application';
|
|
|
|
|
import { copy } from 'ember-copy';
|
|
|
|
|
|
|
|
|
|
export default class CredentialSerializer extends ApplicationSerializer {
|
|
|
|
|
serialize() {
|
2022-07-22 12:29:53 -05:00
|
|
|
const serialized = super.serialize(...arguments);
|
2022-07-20 12:34:18 -07:00
|
|
|
delete serialized['attributes']['password_hmac'];
|
2022-08-12 15:56:19 -05:00
|
|
|
if (serialized.type === 'username_password') {
|
|
|
|
|
delete serialized['attributes']['private_key'];
|
|
|
|
|
delete serialized['attributes']['passphrase'];
|
|
|
|
|
}
|
2022-07-20 12:34:18 -07:00
|
|
|
return serialized;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
normalize(typeClass, hash, ...rest) {
|
|
|
|
|
const normalizedHash = copy(hash, true);
|
|
|
|
|
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
|
|
|
|
|
normalized['data']['attributes']['password'] = '';
|
|
|
|
|
return normalized;
|
|
|
|
|
}
|
|
|
|
|
}
|