refactor: Remove serializeWithNewPassword adapteroptions

This commit is contained in:
Susmitha Girumala committed 2020-09-15 18:11:23 -04:00
1 parent 41f4ef47ed
commit 72e5ad601c
3 files changed
+15 -12

No files matched your search

+1 -2
View File
@@ -19,10 +19,9 @@ export default class AccountModel extends GeneratedAccountModel {
* @param {object} options.adapterOptions
* @return {Promise}
*/
savePassword(password, options={ adapterOptions: {} }) {
setPassword(password, options={ adapterOptions: {} }) {
const defaultAdapterOptions = {
method: 'set-password',
serializeWithNewPassword: true,
password
};
return this.save({
+8 -8
View File
@@ -1,13 +1,12 @@
import ApplicationSerializer from './application';
import { get } from '@ember/object';
export default class AccountSerializer extends ApplicationSerializer {
// =methods
/**
* If `adapterOptions.serializeWithNewPassword` is true, the serialization should
* include **password** and the version.
* If `adapterOptions.method` is `set-password`, the serialization should
* include only **password** and the version.
* If `adapterOptions.password` is set, the serialization should
* include **password** in it's `attributes`.
* @override
@@ -15,11 +14,12 @@ export default class AccountSerializer extends ApplicationSerializer {
* @return {object}
*/
serialize(snapshot) {
const password = get(snapshot, 'adapterOptions.password');
const serializeWithNewPassword = get(snapshot, 'adapterOptions.serializeWithNewPassword');
const password = snapshot?.adapterOptions?.password;
let serialized = super.serialize(...arguments);
if (password) serialized.attributes.password = password;
if (serializeWithNewPassword) serialized = this.serializeWithNewPassword(snapshot, password)
if (password && snapshot?.record?.isNew) serialized.attributes.password = password;
if (snapshot?.adapterOptions?.method === 'set-password') {
serialized = this.serializeForSetPassword(snapshot, password);
}
return serialized;
}
@@ -29,7 +29,7 @@ export default class AccountSerializer extends ApplicationSerializer {
* @param {string} password
* @return {object}
*/
serializeWithNewPassword(snapshot, password) {
serializeForSetPassword(snapshot, password) {
return {
version: snapshot.attr('version'),
password,