{"version":3,"file":"change-user-password.repository-BzsrGdVk.js","sources":["../../../src/packages/user/user/repository/change-password/change-user-password.server.data-source.ts","../../../src/packages/user/user/repository/change-password/change-user-password.repository.ts"],"sourcesContent":["import { UserService } from '@umbraco-cms/backoffice/external/backend-api';\r\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\r\nimport { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';\r\n\r\n/**\r\n * A server data source for changing the password of a user\r\n * @class UmbChangeUserPasswordServerDataSource\r\n */\r\nexport class UmbChangeUserPasswordServerDataSource {\r\n\t#host: UmbControllerHost;\r\n\r\n\t/**\r\n\t * Creates an instance of UmbChangeUserPasswordServerDataSource.\r\n\t * @param {UmbControllerHost} host - The controller host for this controller to be appended to\r\n\t * @memberof UmbChangeUserPasswordServerDataSource\r\n\t */\r\n\tconstructor(host: UmbControllerHost) {\r\n\t\tthis.#host = host;\r\n\t}\r\n\r\n\t/**\r\n\t * Change the password of a user\r\n\t * @param {string} id\r\n\t * @param {string} newPassword\r\n\t * @returns {*}\r\n\t * @memberof UmbChangeUserPasswordServerDataSource\r\n\t */\r\n\tasync changePassword(id: string, newPassword: string) {\r\n\t\tif (!id) throw new Error('User Id is missing');\r\n\r\n\t\treturn tryExecuteAndNotify(\r\n\t\t\tthis.#host,\r\n\t\t\tUserService.postUserByIdChangePassword({\r\n\t\t\t\tid,\r\n\t\t\t\trequestBody: {\r\n\t\t\t\t\tnewPassword,\r\n\t\t\t\t},\r\n\t\t\t}),\r\n\t\t);\r\n\t}\r\n}\r\n","import { UmbUserRepositoryBase } from '../user-repository-base.js';\r\nimport { UmbChangeUserPasswordServerDataSource } from './change-user-password.server.data-source.js';\r\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\r\n\r\nexport class UmbChangeUserPasswordRepository extends UmbUserRepositoryBase {\r\n\t#changePasswordSource: UmbChangeUserPasswordServerDataSource;\r\n\r\n\tconstructor(host: UmbControllerHost) {\r\n\t\tsuper(host);\r\n\t\tthis.#changePasswordSource = new UmbChangeUserPasswordServerDataSource(host);\r\n\t}\r\n\r\n\tasync changePassword(userId: string, newPassword: string) {\r\n\t\tif (!userId) throw new Error('User id is missing');\r\n\t\tif (!newPassword) throw new Error('New password is missing');\r\n\t\tawait this.init;\r\n\r\n\t\tconst { data, error } = await this.#changePasswordSource.changePassword(userId, newPassword);\r\n\r\n\t\tif (!error) {\r\n\t\t\tconst notification = { data: { message: `Password changed` } };\r\n\t\t\tthis.notificationContext?.peek('positive', notification);\r\n\t\t}\r\n\r\n\t\treturn { data, error };\r\n\t}\r\n}\r\n\r\nexport default UmbChangeUserPasswordRepository;\r\n"],"names":["UmbChangeUserPasswordServerDataSource","#host","host","id","newPassword","tryExecuteAndNotify","UserService","UmbChangeUserPasswordRepository","UmbUserRepositoryBase","#changePasswordSource","userId","data","error","notification"],"mappings":";;;AAQO,MAAMA,EAAsC;AAAA,EAClDC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAYC,GAAyB;AACpC,SAAKD,KAAQC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUd,MAAM,eAAeC,GAAYC,GAAqB;AACrD,QAAI,CAACD,EAAU,OAAA,IAAI,MAAM,oBAAoB;AAEtC,WAAAE;AAAA,MACN,KAAKJ;AAAA,MACLK,EAAY,2BAA2B;AAAA,QACtC,IAAAH;AAAA,QACA,aAAa;AAAA,UACZ,aAAAC;AAAA,QAAA;AAAA,MAED,CAAA;AAAA,IACF;AAAA,EAAA;AAEF;ACpCO,MAAMG,UAAwCC,EAAsB;AAAA,EAC1EC;AAAA,EAEA,YAAYP,GAAyB;AACpC,UAAMA,CAAI,GACL,KAAAO,KAAwB,IAAIT,EAAsCE,CAAI;AAAA,EAAA;AAAA,EAG5E,MAAM,eAAeQ,GAAgBN,GAAqB;AACzD,QAAI,CAACM,EAAc,OAAA,IAAI,MAAM,oBAAoB;AACjD,QAAI,CAACN,EAAmB,OAAA,IAAI,MAAM,yBAAyB;AAC3D,UAAM,KAAK;AAEL,UAAA,EAAE,MAAAO,GAAM,OAAAC,MAAU,MAAM,KAAKH,GAAsB,eAAeC,GAAQN,CAAW;AAE3F,QAAI,CAACQ,GAAO;AACX,YAAMC,IAAe,EAAE,MAAM,EAAE,SAAS,qBAAqB;AACxD,WAAA,qBAAqB,KAAK,YAAYA,CAAY;AAAA,IAAA;AAGjD,WAAA,EAAE,MAAAF,GAAM,OAAAC,EAAM;AAAA,EAAA;AAEvB;"}