feat: 🎸 implement API for change password
This commit is contained in:
3 files changed
+72
No files matched your search
@@ -20,6 +20,11 @@ export default class AccountSerializer extends ApplicationSerializer {
|
||||
if (snapshot?.adapterOptions?.method === 'set-password') {
|
||||
serialized = this.serializeForSetPassword(snapshot, password);
|
||||
}
|
||||
if (snapshot?.adapterOptions?.method === 'change-password') {
|
||||
const { currentPassword, newPassword } = snapshot?.adapterOptions;
|
||||
serialized =
|
||||
this.serializeForChangePassword(snapshot, currentPassword, newPassword);
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
|
||||
@@ -35,4 +40,19 @@ export default class AccountSerializer extends ApplicationSerializer {
|
||||
password,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a payload containing current and new passwords.
|
||||
* @param {Snapshot} snapshot
|
||||
* @param {string} current_password
|
||||
* @param {string} new_password
|
||||
* @return {object}
|
||||
*/
|
||||
serializeForChangePassword(snapshot, current_password, new_password) {
|
||||
return {
|
||||
version: snapshot.attr('version'),
|
||||
current_password,
|
||||
new_password,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user