import { ApiError, rpc, type Envelope } from './client'; /** The CHANGE_PASSWORD action on USERS, for the signed-in user's own account. */ export async function changePassword(userId: number, oldPassword: string, newPassword: string, confirmPassword: string) { const res = await rpc( 'USERS', 'CHANGE_PASSWORD', { id: userId, data: { OLDPASSWORD: oldPassword, NEWPASSWORD: newPassword, conpassword: confirmPassword } }, { post: true }, ); if (String(res.CODE) !== '000' && res.CODE !== 0) { throw new ApiError(String(res.MESSAGECODE ?? res.MESSAGE ?? 'ACTION_FAILED'), res.CODE); } return res; }