add(settings): password changing

This commit is contained in:
AdrienLSH
2024-03-19 13:59:21 +01:00
parent a3be4681cc
commit 68ceec22eb
13 changed files with 234 additions and 99 deletions

View File

@ -67,6 +67,30 @@ class Account
}
return respondeData['authorize'] || respondeData['detail'] || respondeData['username']?.join(' ') || 'Error.';
}
async updatePassword(currentPassword, newPassword, newPassword2)
{
const data = {
current_password: currentPassword,
new_password: newPassword,
new_password2: newPassword2
};
const response = await this.client._put('/api/accounts/update_password', data);
if (response.ok)
return null;
const responseData = await response.json();
const formatedData = {};
if (responseData['current_password'])
formatedData['currentPasswordDetail'] = responseData['current_password'];
if (responseData['new_password'])
formatedData['newPasswordDetail'] = responseData['new_password'];
if (responseData['new_password2'])
formatedData['newPassword2Detail'] = responseData['new_password2'];
if (formatedData == {})
formatedData['passwordDetail'] = 'Error';
return formatedData;
}
}
export { Account };