storemw-core-api 1.0.144 → 1.0.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/subscription/plan/subscribePlanController.js +4 -0
- package/dist/controllers/subscription/plan/subscribePlanController.js.map +1 -1
- package/dist/features/auth_token/authTokenType.d.ts +1 -1
- package/dist/features/auth_token/authTokenType.js.map +1 -1
- package/dist/features/index.d.ts +3 -0
- package/dist/features/index.js +5 -1
- package/dist/features/index.js.map +1 -1
- package/dist/features/user_me/userMeRegister.d.ts +5 -0
- package/dist/features/user_me/userMeRegister.js +11 -0
- package/dist/features/user_me/userMeRegister.js.map +1 -0
- package/dist/features/user_me/userMeRegistry.d.ts +2 -0
- package/dist/features/user_me/userMeRegistry.js +32 -0
- package/dist/features/user_me/userMeRegistry.js.map +1 -0
- package/dist/features/user_me/userMeType.d.ts +8 -0
- package/dist/features/user_me/userMeType.js +3 -0
- package/dist/features/user_me/userMeType.js.map +1 -0
- package/dist/models/subscription/plan/SubscribePlanModel.d.ts +13 -2
- package/dist/schema/payload/subscription/schemaSubscribePlan.d.ts +17 -0
- package/dist/schema/payload/subscription/schemaSubscribePlan.js +1 -0
- package/dist/schema/payload/subscription/schemaSubscribePlan.js.map +1 -1
- package/dist/services/auth/AuthService.js +4 -1
- package/dist/services/auth/AuthService.js.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/subscription/account/AccountSubscribeService.js +21 -0
- package/dist/services/subscription/account/AccountSubscribeService.js.map +1 -1
- package/dist/services/subscription/plan/SubscribePlanService.d.ts +2 -0
- package/dist/services/subscription/plan/SubscribePlanService.js +3 -0
- package/dist/services/subscription/plan/SubscribePlanService.js.map +1 -1
- package/dist/services/user/UserMeService.js +24 -211
- package/dist/services/user/UserMeService.js.map +1 -1
- package/package.json +1 -1
- package/prisma/schema.prisma +16 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User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AS,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE;QACvE,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE;QAChF,oBAAoB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,yBAAyB,EAAE;QACzG,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE;KACnF,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,eAAe,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEhE,CAAC,CAAA;AA1ZY,QAAA,aAAa,iBA0ZzB","sourcesContent":["import {\n UserModel,\n ModelCountry,\n CountryModel,\n ModelUserFields,\n ModelAdministratorFields,\n ModelCountryFields\n} from \"@/models\";\n\nimport { z } from \"zod\";\n\nimport { UserPropService, UserPropReplaceProps } from \"./UserPropService\";\n// import { CustomerGetProps, CustomerCreateProps, CustomerListProps, CustomerUpdateProps, CustomerService } from \"./CustomerService\";\n// import { AdministratorGetProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorListProps, AdministratorService } from \"./AdministratorService\";\n// import { WorkerCreateProps, WorkerGetProps, WorkerUpdateProps, WorkerListProps, WorkerService } from \"./WorkerService\";\n// import { DriverCreateProps, DriverGetProps, DriverUpdateProps, DriverListProps, DriverService } from \"./DriverService\";\n// import { RetailerCreateProps, RetailerGetProps, RetailerUpdateProps, RetailerListProps, RetailerService } from \"./RetailerService\";\n// import { MemberCreateProps, MemberGetProps, MemberUpdateProps, MemberListProps, MemberService } from \"./MemberService\";\n// import { AgentCreateProps, AgentGetProps, AgentUpdateProps, AgentListProps, AgentService } from \"./AgentService\";\n// import { OperatorCreateProps, OperatorGetProps, OperatorListProps, OperatorService, OperatorUpdateProps } from \"./OperatorService\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n// import { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { verifyPassword, validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\n// import { hashPassword } from \"@/utils\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nimport { UserService, AccountService, UserUpdateProps } from \"@/services\";\n\nexport const userTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n supplier: \"supplier\",\n customer: \"customer\",\n driver: \"driver\",\n retailer: \"retailer\",\n member: \"member\",\n agent: \"agent\",\n} as const\n\nexport type UserType = typeof userTypes[keyof typeof userTypes]\n\nexport type UserMeServiceProps = DefaultServiceProps & {\n // userType: UserType\n};\n\nexport type UserMeChangePasswordProps = {\n currentPassword: string\n newPassword: string\n confirmPassword: string\n};\n\nexport type UserMeUpdateProps = {\n firstName: string\n lastName: string\n address: string\n};\n\n// const getUpdatePayload = async (\n// userType: UserType,\n// data: UserMeUpdateProps[\"data\"],\n// contact: {\n// countryCode: number,\n// phoneNumber: string\n// }\n// ) => {\n\n// if (\"user\" in data) {\n\n// const newHashPassword = data?.user?.loginPassword ? await hashPassword(data.user.loginPassword) : \"\"\n\n// return {\n// [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n// ...(newHashPassword ? { [`${ModelUserFields.login_password}`]: newHashPassword } : {}),\n// [`${ModelUserFields.address}`]: data.user.address,\n// [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n// [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n// [`${ModelUserFields.email}`]: data.user.email,\n// [`${ModelUserFields.firstname}`]: data.user.firstname,\n// [`${ModelUserFields.lastname}`]: data.user.lastname,\n// [`${ModelUserFields.status}`]: Boolean(data.user.status),\n// [`${ModelUserFields.user_type}`]: `${userType}`\n// }\n// }\n\n// return false\n\n// }\n\nexport const UserMeService = (props: UserMeServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const userType = rest.actionUserType as UserType\n const userId = rest.actionUserId\n\n const userService = UserService({ ...rest, userType })\n const userModel = UserModel({ ...rest })\n\n // const userModel = UserModel({ ...rest })\n\n // const userPropService = UserPropService({ ...rest, userPropType: \"LOCATION_ID\" })\n // const customerService = CustomerService({ ...rest })\n // const administratorService = AdministratorService({ ...rest })\n // const operatorService = OperatorService({ ...rest })\n // const workerService = WorkerService({ ...rest })\n // const driverService = DriverService({ ...rest })\n // const retailerService = RetailerService({ ...rest })\n // const memberService = MemberService({ ...rest })\n // const agentService = AgentService({ ...rest })\n\n // const validateAuthToken = (token: string) => {\n\n // // retrive core configuration\n // const coreConfig = getCoreConfiguration()\n\n // // const authSecretKey = config.AUTH_SECRET_KEY\n // const authSecretKey = coreConfig.authSecretKey\n\n // // const jwtData = jwt.verify(token, authSecretKey) as AuthJwtToken; // Verify JWT token\n // const jwtData = verifyAuthToken(token, authSecretKey); // Verify JWT token\n\n // }\n\n // const validateAuthAccessKey = async (accessKey: string) => {\n\n // const accessKeyUtilService = AccessKeyUtilService({\n // accessKeyUserType: \"administrator\",\n // accountId: 0,\n // actionUserId: 0,\n // actionUserType: \"\",\n // authToken: \"\",\n // isOperator: true,\n // })\n\n // const accessKeyData = await accessKeyUtilService.validateAccessKey({ data: { accessKey } });\n // }\n\n // const updateMe = async ({ id, data, userType: overrideUserType }: UserMeUpdateProps) => {\n\n // const _userType = overrideUserType || userType\n\n // // validate the credential contact no\n // const userLoginUsername = data.user.loginUsername\n // const userLoginPassword = data.user?.loginPassword ?? \"\"\n // const userContactCountryCode = data.user.contact.countryCode\n // const userContactPhoneNumber = data.user.contact.phoneNumber\n\n // // validate the contact no only can be digit in text only\n // // validate the country code in prefix\n // // await validateUserContact(userContactCountryCode, userContactPhoneNumber)\n\n // // validate login username\n // // validateLoginUsernameFormat(userLoginUsername)\n\n // // validate login password\n // // if (userLoginPassword) {\n // // validateLoginPasswordFormat(userLoginPassword)\n // // }\n\n // // check the username duplicated?\n // const checkUsername = await userModel.list({\n // limit: 1,\n // offset: 0,\n // orderBy: {\n // [`${ModelUserFields.user_id}`]: \"asc\"\n // },\n // include: [],\n // where: {\n // [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n // [`${ModelUserFields.isdelete}`]: false,\n // [`${ModelUserFields.istrash}`]: false,\n // [`${ModelUserFields.accountid}`]: rest.accountId,\n // },\n // })\n\n // // console.log('ch', checkUsername)\n\n // if (checkUsername.length > 0) {\n // if (Number(checkUsername[0]?.user_id) !== Number(id)) { // if not self user id\n // throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n // }\n // }\n\n // // validation before insertion\n // // if (_userType === \"member\" && \"member\" in data) {\n // // }\n\n // const _data = await getUpdatePayload(\n // _userType,\n // data,\n // {\n // countryCode: userContactCountryCode,\n // phoneNumber: userContactPhoneNumber\n // }\n // )\n\n // if (!_data) {\n // throw new Error(`Invalid update payload: ${JSON.stringify(_data)}`);\n // }\n\n // // update user\n // let responseUser = await userModel.update({ id, data: _data })\n\n // let updateUserId = responseUser.user_id\n\n // let response: any = {}\n\n // if (_userType === \"customer\" && \"customer\" in data) {\n\n // let dataCustomer: CustomerUpdateProps[\"data\"] = {\n // customer: {\n // ...data.customer\n // }\n // }\n\n // await customerService.updateCustomer({ userId: Number(updateUserId), data: dataCustomer })\n\n // response = await customerService.getCustomer({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"operator\" && \"operator\" in data) {\n\n // let dataOperator: OperatorUpdateProps[\"data\"] = {\n // operator: {\n // ...data.operator\n // }\n // }\n\n // await operatorService.updateOperator({ userId: Number(updateUserId), data: dataOperator })\n\n // response = await operatorService.getOperator({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"administrator\" && \"administrator\" in data) {\n\n // let dataCustomer: AdministratorUpdateProps[\"data\"] = {\n // administrator: {\n // ...data.administrator\n // }\n // }\n\n // await administratorService.updateAdministrator({ userId: Number(updateUserId), data: dataCustomer })\n\n // // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n // response = await administratorService.getAdministrator({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"worker\" && \"worker\" in data) {\n\n // let dataWorker: WorkerUpdateProps[\"data\"] = {\n // worker: {\n // ...data.worker\n // }\n // }\n\n // await workerService.updateWorker({ userId: Number(updateUserId), data: dataWorker })\n\n // // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n // response = await workerService.getWorker({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"driver\" && \"driver\" in data) {\n\n // let dataDriver: DriverUpdateProps[\"data\"] = {\n // driver: {\n // ...data.driver\n // }\n // }\n\n // await driverService.updateDriver({ userId: Number(updateUserId), data: dataDriver })\n\n // // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n // response = await driverService.getDriver({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"member\" && \"member\" in data) {\n\n // let dataMember: MemberUpdateProps[\"data\"] = {\n // member: {\n // ...data.member\n // }\n // }\n\n // await memberService.updateMember({ userId: Number(updateUserId), data: dataMember })\n\n // // replace user prop\n // // await userPropService.replaceUserProp({\n // // userPropType: \"LOCATION_ID\",\n // // data: {\n // // userProp: {\n // // userId: Number(updateUserId),\n // // locationIds: data.props.locationIds\n // // }\n // // }\n // // })\n\n // response = await memberService.getUserMember({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"agent\" && \"agent\" in data) {\n\n // let dataAgent: AgentUpdateProps[\"data\"] = {\n // agent: {\n // ...data.agent\n // }\n // }\n\n // await agentService.updateAgent({ userId: Number(updateUserId), data: dataAgent })\n\n // // replace user prop\n // // await userPropService.replaceUserProp({\n // // userPropType: \"LOCATION_ID\",\n // // data: {\n // // userProp: {\n // // userId: Number(updateUserId),\n // // locationIds: data.props.locationIds\n // // }\n // // }\n // // })\n\n // response = await agentService.getAgent({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // if (_userType === \"retailer\" && \"retailer\" in data) {\n\n // let dataRetailer: RetailerUpdateProps[\"data\"] = {\n // retailer: {\n // ...data.retailer\n // }\n // }\n\n // await retailerService.updateRetailer({ userId: Number(updateUserId), data: dataRetailer })\n\n // response = await retailerService.getRetailer({ id: Number(updateUserId), datatypes: [] })\n\n // }\n\n // return response\n // }\n\n const getUserMe = async () => {\n\n const id = userId\n\n const data = await userService.getUser({ id: userId, datatypes: [] })\n\n return data\n };\n\n const updateUserMe = async ({\n firstName = \"\",\n lastName = \"\",\n address = \"\"\n }: UserMeUpdateProps) => {\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // console.log('user', user)\n\n // check the userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n // change user information\n await userModel.update({\n id: Number(userId),\n data: {\n [`${ModelUserFields.firstname}`]: firstName,\n [`${ModelUserFields.lastname}`]: lastName,\n [`${ModelUserFields.address}`]: address,\n }\n })\n\n return await userService.getUser({ id: Number(userId), datatypes: [] })\n\n }\n\n const removeUserMe = async () => {\n\n const response = await userService.suspendUsers({ ids: [BigInt(userId)] })\n\n return response\n };\n\n const changePasswordUserMe = async ({\n currentPassword,\n confirmPassword,\n newPassword\n }: UserMeChangePasswordProps) => {\n\n const accountId = rest?.accountId ?? 0\n const accountService = AccountService({ ...rest, isOperator: true })\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [], includePassword: true })\n const account = await accountService.getAccount({ id: Number(accountId), datatypes: [] })\n\n // console.log('user', user)\n // console.log('account', account)\n\n // check the accountId / userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n if (Object.keys(account).length <= 0) { // must have account id record\n throwError(`Invalid account id in auth token`)\n }\n\n // new password cannot same with current password\n if (newPassword === currentPassword) {\n throwError(`New and current password cannot be same`)\n }\n\n // new password must same with confirm\n if (newPassword !== confirmPassword) {\n throwError(`New and confirm password not matched`)\n }\n\n // validate the login password new format\n validateLoginPasswordFormat(newPassword);\n\n // check the current password\n try {\n const decryptedPass = await verifyPassword(currentPassword, user?.password)\n // console.log('decryptedPass', decryptedPass)\n\n if (!decryptedPass) {\n throw Error(`Invalid current password`)\n }\n\n } catch (error: any) {\n throwError(`Auth Token: ${error?.message}`)\n }\n\n // perform update credential\n const responseUser = await userService.replacePassword({\n id: Number(userId),\n data: {\n unhashLoginPassword: newPassword\n },\n isOperator: Boolean(userType === \"operator\")\n })\n\n return responseUser\n\n }\n\n const allowUserTypes = [\"any\"] as const\n\n const methodConfigs = {\n getUserMe: { fn: getUserMe, allowUserTypes, actionName: \"get user/me\" },\n updateUserMe: { fn: updateUserMe, allowUserTypes, actionName: \"update user/me\" },\n changePasswordUserMe: { fn: changePasswordUserMe, allowUserTypes, actionName: \"change password user/me\" },\n removeUserMe: { fn: removeUserMe, allowUserTypes, actionName: \"remove user/me\" },\n };\n\n return ServiceFactory(\"UserMeService\", rest, methodConfigs);\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"UserMeService.js","sourceRoot":"","sources":["../../../src/services/user/UserMeService.ts"],"names":[],"mappings":";;;AAAA,qCAGkB;AAElB,mCAAuG;AAEvG,+BAAuC;AAEvC,yCAAyD;AAEzD,yCAAkJ;AAErI,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAA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AE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE;KACnF,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,eAAe,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEhE,CAAC,CAAA;AAhKY,QAAA,aAAa,iBAgKzB","sourcesContent":["import {\n UserModel,\n ModelUserFields\n} from \"@/models\";\n\nimport { verifyPassword, validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nimport { UserService, AccountService } from \"@/services\";\n\nimport { UserMeHook, FeatureUserMeSuccessUpdateProps, FeatureUserMeSuccessChangePasswordProps, FeatureUserMeSuccessRemoveProps } from \"@/features\"\n\nexport const userTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n supplier: \"supplier\",\n customer: \"customer\",\n driver: \"driver\",\n retailer: \"retailer\",\n member: \"member\",\n agent: \"agent\",\n} as const\n\nexport type UserType = typeof userTypes[keyof typeof userTypes]\n\nexport type UserMeServiceProps = DefaultServiceProps & {\n // userType: UserType\n};\n\nexport type UserMeChangePasswordProps = {\n currentPassword: string\n newPassword: string\n confirmPassword: string\n};\n\nexport type UserMeUpdateProps = {\n firstName: string\n lastName: string\n address: string\n};\n\n// const getUpdatePayload = async (\n// userType: UserType,\n// data: UserMeUpdateProps[\"data\"],\n// contact: {\n// countryCode: number,\n// phoneNumber: string\n// }\n// ) => {\n\n// if (\"user\" in data) {\n\n// const newHashPassword = data?.user?.loginPassword ? await hashPassword(data.user.loginPassword) : \"\"\n\n// return {\n// [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n// ...(newHashPassword ? { [`${ModelUserFields.login_password}`]: newHashPassword } : {}),\n// [`${ModelUserFields.address}`]: data.user.address,\n// [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n// [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n// [`${ModelUserFields.email}`]: data.user.email,\n// [`${ModelUserFields.firstname}`]: data.user.firstname,\n// [`${ModelUserFields.lastname}`]: data.user.lastname,\n// [`${ModelUserFields.status}`]: Boolean(data.user.status),\n// [`${ModelUserFields.user_type}`]: `${userType}`\n// }\n// }\n\n// return false\n\n// }\n\nexport const UserMeService = (props: UserMeServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const userType = rest.actionUserType as UserType\n const userId = rest.actionUserId\n\n const userService = UserService({ ...rest, userType })\n const userModel = UserModel({ ...rest })\n\n const getUserMe = async () => {\n\n const id = userId\n\n const data = await userService.getUser({ id: userId, datatypes: [] })\n\n return data\n };\n\n const updateUserMe = async ({\n firstName = \"\",\n lastName = \"\",\n address = \"\"\n }: UserMeUpdateProps) => {\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // console.log('user', user)\n\n // check the userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n // change user information\n await userModel.update({\n id: Number(userId),\n data: {\n [`${ModelUserFields.firstname}`]: firstName,\n [`${ModelUserFields.lastname}`]: lastName,\n [`${ModelUserFields.address}`]: address,\n }\n })\n\n const userMe = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // Call the consumer hook, if success\n if (UserMeHook.onSuccessUpdateMe) {\n await UserMeHook.onSuccessUpdateMe({\n userMe\n })\n }\n\n return userMe\n\n }\n\n const removeUserMe = async () => {\n\n const currentMe = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n const response = await userService.suspendUsers({ ids: [BigInt(userId)] })\n\n // Call the consumer hook, if remove\n if (UserMeHook.onSuccessRemoveMe) {\n await UserMeHook.onSuccessRemoveMe({\n userMe: currentMe\n })\n }\n\n return response\n };\n\n const changePasswordUserMe = async ({\n currentPassword,\n confirmPassword,\n newPassword\n }: UserMeChangePasswordProps) => {\n\n const accountId = rest?.accountId ?? 0\n const accountService = AccountService({ ...rest, isOperator: true })\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [], includePassword: true })\n const account = await accountService.getAccount({ id: Number(accountId), datatypes: [] })\n\n // console.log('user', user)\n // console.log('account', account)\n\n // check the accountId / userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n if (Object.keys(account).length <= 0) { // must have account id record\n throwError(`Invalid account id in auth token`)\n }\n\n // new password cannot same with current password\n if (newPassword === currentPassword) {\n throwError(`New and current password cannot be same`)\n }\n\n // new password must same with confirm\n if (newPassword !== confirmPassword) {\n throwError(`New and confirm password not matched`)\n }\n\n // validate the login password new format\n validateLoginPasswordFormat(newPassword);\n\n // check the current password\n try {\n const decryptedPass = await verifyPassword(currentPassword, user?.password)\n // console.log('decryptedPass', decryptedPass)\n\n if (!decryptedPass) {\n throw Error(`Invalid current password`)\n }\n\n } catch (error: any) {\n throwError(`Auth Token: ${error?.message}`)\n }\n\n // perform update credential\n const responseUser = await userService.replacePassword({\n id: Number(userId),\n data: {\n unhashLoginPassword: newPassword\n },\n isOperator: Boolean(userType === \"operator\")\n })\n\n // Call the consumer hook, if change password\n if (UserMeHook.onSuccessChangePasswordMe) {\n\n // remove the password\n delete user.password\n\n await UserMeHook.onSuccessChangePasswordMe({\n userMe: user\n })\n }\n\n return responseUser\n\n }\n\n const allowUserTypes = [\"any\"] as const\n\n const methodConfigs = {\n getUserMe: { fn: getUserMe, allowUserTypes, actionName: \"get user/me\" },\n updateUserMe: { fn: updateUserMe, allowUserTypes, actionName: \"update user/me\" },\n changePasswordUserMe: { fn: changePasswordUserMe, allowUserTypes, actionName: \"change password user/me\" },\n removeUserMe: { fn: removeUserMe, allowUserTypes, actionName: \"remove user/me\" },\n };\n\n return ServiceFactory(\"UserMeService\", rest, methodConfigs);\n\n}\n\n"]}
|
package/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -2847,21 +2847,22 @@ model agents {
|
|
|
2847
2847
|
}
|
|
2848
2848
|
|
|
2849
2849
|
model subscribe_plans {
|
|
2850
|
-
subscribe_plan_id
|
|
2851
|
-
createdatetime
|
|
2852
|
-
createuserid
|
|
2853
|
-
updatedatetime
|
|
2854
|
-
updateuserid
|
|
2855
|
-
isdelete
|
|
2856
|
-
istrash
|
|
2857
|
-
accountid
|
|
2858
|
-
name
|
|
2859
|
-
short_description
|
|
2860
|
-
full_description
|
|
2861
|
-
price
|
|
2862
|
-
currency
|
|
2863
|
-
billing_cycle
|
|
2864
|
-
status
|
|
2850
|
+
subscribe_plan_id BigInt @id(map: "subscribe_plan_pkey") @default(autoincrement())
|
|
2851
|
+
createdatetime DateTime? @db.Timestamptz(6)
|
|
2852
|
+
createuserid BigInt @default(0)
|
|
2853
|
+
updatedatetime DateTime? @db.Timestamptz(6)
|
|
2854
|
+
updateuserid BigInt @default(0)
|
|
2855
|
+
isdelete Boolean? @default(false)
|
|
2856
|
+
istrash Boolean? @default(false)
|
|
2857
|
+
accountid BigInt @default(0)
|
|
2858
|
+
name String @db.VarChar(100)
|
|
2859
|
+
short_description String? @db.VarChar(255)
|
|
2860
|
+
full_description String?
|
|
2861
|
+
price Decimal @db.Decimal(10, 2)
|
|
2862
|
+
currency String @default("MYR") @db.Char(3)
|
|
2863
|
+
billing_cycle String @db.VarChar(20)
|
|
2864
|
+
status Boolean? @default(false)
|
|
2865
|
+
is_single_subscription Boolean @default(true)
|
|
2865
2866
|
|
|
2866
2867
|
@@schema("public")
|
|
2867
2868
|
}
|