'use strict';
import { getUserById } from '../../fd-app-toolbox/server/users/user-db.js';
import { hash, verify } from '@node-rs/argon2';
import { updateResource } from '../../meta/server/db/db.js';
import { resourceNames } from '../../../fd-toolbox/resources/resource-names.js';

var __defProp=Object['defineProperty'],__name=(_0x4af892,_0x2914f2)=>__defProp(_0x4af892,'name',{'value':_0x2914f2,'configurable':!![]});async function changeUserPassword(_0x30d9fc,_0x1f086f){let _0x22c9be={'isSuccess':!![],'userFriendlyMessage':''};const _0x103fa0=await getUserById(_0x1f086f);if(!_0x30d9fc['newPassword']||!_0x103fa0)return _0x22c9be;if(!_0x30d9fc['currentPassword'])return _0x22c9be={'isSuccess':![],'userFriendlyMessage':'Current\x20password\x20cannot\x20be\x20null\x20or\x20empty'},_0x22c9be;return changePasswordAsync(_0x103fa0,_0x30d9fc['currentPassword'],_0x30d9fc['newPassword']);}__name(changeUserPassword,'changeUserPassword');async function changePasswordAsync(_0x474923,_0x553033,_0x23b252){const _0x179277=await hash(_0x23b252,{'memoryCost':0x4c00,'timeCost':0x2,'outputLen':0x20,'parallelism':0x1}),_0x1aaa9d={'isSuccess':!![],'userFriendlyMessage':''};if(!await verify(_0x474923['passwordHash'],_0x553033))return _0x1aaa9d['isSuccess']=![],_0x1aaa9d['userFriendlyMessage']='Passwords\x20aren\x27t\x20match',_0x1aaa9d;return _0x474923['passwordHash']=_0x179277,await updateResource(_0x474923,resourceNames['user']),_0x1aaa9d;}__name(changePasswordAsync,'changePasswordAsync');

export { changeUserPassword };
