'use strict';
import { apiBadRequestResponse, apiOkResponse } from '../../../meta/server/web/responses.js';
import { changeUserPassword } from '../../users/user-service.js';
import { parseJsonBodyFromRequest } from '../../../../fd-toolbox/lib/utils.js';
import { getUserId } from '../../../meta/server/auth/users/current-user-id-provider.js';
import { basicErrorMessages } from '../../../../base-repo/constants/internal-common-strings.js';

var __defProp=Object['defineProperty'],__name=(_0x23b5bf,_0x325e7c)=>__defProp(_0x23b5bf,'name',{'value':_0x325e7c,'configurable':!![]});async function editpasswordPutRoute(_0x3b2722){const _0x46fd3c=await parseJsonBodyFromRequest(_0x3b2722),_0x159c83=await getUserId();let _0x92ebe0;if(!_0x159c83)_0x92ebe0=apiBadRequestResponse(basicErrorMessages['userNotFound']);else {if(!_0x46fd3c['currentPassword'])_0x92ebe0=apiBadRequestResponse('Current\x20password\x20is\x20required');else {if(!_0x46fd3c['newPassword'])_0x92ebe0=apiBadRequestResponse('New\x20password\x20is\x20required');else {const _0x3552c1=await changeUserPassword(_0x46fd3c,_0x159c83);_0x92ebe0=_0x3552c1['isSuccess']?apiOkResponse('Password\x20successfully\x20changed'):apiBadRequestResponse(_0x3552c1['userFriendlyMessage']);}}}return _0x92ebe0;}__name(editpasswordPutRoute,'editpasswordPutRoute');

export { editpasswordPutRoute };
