open-vault/ui/app/serializers/clients/config.js
Jordan Reimer b936db8332
Revert "MFA (#14049)" (#14135)
This reverts commit 5f17953b5980e6438215d5cb62c8575d16c63193.
2022-02-17 13:17:59 -07:00

33 lines
1 KiB
JavaScript

import ApplicationSerializer from '../application';
export default ApplicationSerializer.extend({
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
if (!payload.data) {
// CBS TODO: Remove this if block once API is published
return this._super(store, primaryModelClass, payload, id, requestType);
}
const normalizedPayload = {
id: payload.id,
data: {
...payload.data,
enabled: payload.data.enabled?.includes('enable') ? 'On' : 'Off',
},
};
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
},
serialize() {
let json = this._super(...arguments);
if (json.enabled === 'On' || json.enabled === 'Off') {
const oldEnabled = json.enabled;
json.enabled = oldEnabled === 'On' ? 'enable' : 'disable';
}
json.retention_months = parseInt(json.retention_months, 10);
if (isNaN(json.retention_months)) {
throw new Error('Invalid number value');
}
delete json.queries_available;
return json;
},
});