storemw-core-api 1.0.139 → 1.0.140
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/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -2
- package/dist/controllers/index.js +5 -4
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/user/userMeController.d.ts +3 -0
- package/dist/controllers/user/userMeController.js +52 -361
- package/dist/controllers/user/userMeController.js.map +1 -1
- package/dist/controllers/utils/unuse/changePasswordUtilController.d.ts +1 -0
- package/dist/controllers/utils/unuse/changePasswordUtilController.js +55 -0
- package/dist/controllers/utils/unuse/changePasswordUtilController.js.map +1 -0
- package/dist/middlewares/route/index.d.ts +1 -1
- package/dist/middlewares/route/index.js +4 -2
- package/dist/middlewares/route/index.js.map +1 -1
- package/dist/middlewares/route/validateUserMe.d.ts +2 -0
- package/dist/middlewares/route/validateUserMe.js +9 -1
- package/dist/middlewares/route/validateUserMe.js.map +1 -1
- package/dist/routes/index.d.ts +0 -1
- package/dist/routes/index.js +2 -3
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/user/userMeRoutes.js +4 -0
- package/dist/routes/user/userMeRoutes.js.map +1 -1
- package/dist/routes/utils/unuse/changePasswordUtilRoutes.d.ts +1 -0
- package/dist/routes/utils/unuse/changePasswordUtilRoutes.js +10 -0
- package/dist/routes/utils/unuse/changePasswordUtilRoutes.js.map +1 -0
- package/dist/schema/payload/index.d.ts +2 -2
- package/dist/schema/payload/index.js +7 -4
- package/dist/schema/payload/index.js.map +1 -1
- package/dist/schema/payload/user/schemaUserMe.d.ts +31 -0
- package/dist/schema/payload/user/schemaUserMe.js +17 -0
- package/dist/schema/payload/user/schemaUserMe.js.map +1 -0
- package/dist/schema/payload/utils/unuse/schemaChangePasswordUtil.d.ts +53 -0
- package/dist/schema/payload/utils/unuse/schemaChangePasswordUtil.js +18 -0
- package/dist/schema/payload/utils/unuse/schemaChangePasswordUtil.js.map +1 -0
- package/dist/services/auth/AuthService.js +4 -1
- package/dist/services/auth/AuthService.js.map +1 -1
- package/dist/services/index.d.ts +1 -3
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +1 -1
- package/dist/services/user/UserMeService.d.ts +30 -7
- package/dist/services/user/UserMeService.js +71 -3
- package/dist/services/user/UserMeService.js.map +1 -1
- package/dist/services/user/UserService.d.ts +22 -1
- package/dist/services/user/UserService.js +21 -22
- package/dist/services/user/UserService.js.map +1 -1
- package/dist/services/utils/unuse/ChangePasswordUtilService.d.ts +13 -0
- package/dist/services/utils/unuse/ChangePasswordUtilService.js +78 -0
- package/dist/services/utils/unuse/ChangePasswordUtilService.js.map +1 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/passwordUtils.d.ts +3 -0
- package/dist/utils/passwordUtils.js +22 -0
- package/dist/utils/passwordUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserService = exports.
|
|
3
|
+
exports.UserService = exports.loginUsernameSchema = exports.loginUsernameReservedWords = exports.userTypes = void 0;
|
|
4
4
|
const models_1 = require("../../models");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const UserPropService_1 = require("./UserPropService");
|
|
@@ -110,13 +110,6 @@ exports.loginUsernameSchema = zod_1.z
|
|
|
110
110
|
.refine((val) => !exports.loginUsernameReservedWords.includes(val), {
|
|
111
111
|
message: "This login username is reserved. Please choose another one",
|
|
112
112
|
});
|
|
113
|
-
// Zod schema for password
|
|
114
|
-
exports.loginPasswordSchema = zod_1.z
|
|
115
|
-
.string()
|
|
116
|
-
.min(8, { message: "Password must be at least 8 characters" })
|
|
117
|
-
.max(64, { message: "Password must be at most 64 characters" })
|
|
118
|
-
.regex(/[a-zA-Z]/, "Password must include at least one letter")
|
|
119
|
-
.regex(/[0-9!@#$%^&*()_\-+=]/, "Password must include at least one number or special character");
|
|
120
113
|
const UserService = (props) => {
|
|
121
114
|
const { userType = "administrator", ...rest } = props;
|
|
122
115
|
const userModel = (0, models_1.UserModel)({ ...rest });
|
|
@@ -182,18 +175,6 @@ const UserService = (props) => {
|
|
|
182
175
|
throw err;
|
|
183
176
|
}
|
|
184
177
|
};
|
|
185
|
-
const validateLoginPasswordFormat = (loginPassword) => {
|
|
186
|
-
try {
|
|
187
|
-
return exports.loginPasswordSchema.parse(loginPassword); // throws if invalid
|
|
188
|
-
}
|
|
189
|
-
catch (err) {
|
|
190
|
-
if (err instanceof zod_1.z.ZodError) {
|
|
191
|
-
throw new Error(`Invalid login password: "${loginPassword}". ` +
|
|
192
|
-
err.errors.map((e) => e.message).join("; "));
|
|
193
|
-
}
|
|
194
|
-
throw err;
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
178
|
const createUser = async ({ data, userType: overrideUserType }) => {
|
|
198
179
|
const _userType = overrideUserType || userType;
|
|
199
180
|
// validate the credential contact no
|
|
@@ -207,7 +188,7 @@ const UserService = (props) => {
|
|
|
207
188
|
// validate login username
|
|
208
189
|
validateLoginUsernameFormat(userLoginUsername);
|
|
209
190
|
// validate login password
|
|
210
|
-
validateLoginPasswordFormat(userLoginPassword);
|
|
191
|
+
(0, utils_1.validateLoginPasswordFormat)(userLoginPassword);
|
|
211
192
|
// check the username duplicated?
|
|
212
193
|
const checkUsername = await userModel.list({
|
|
213
194
|
limit: 1,
|
|
@@ -406,7 +387,7 @@ const UserService = (props) => {
|
|
|
406
387
|
validateLoginUsernameFormat(userLoginUsername);
|
|
407
388
|
// validate login password
|
|
408
389
|
if (userLoginPassword) {
|
|
409
|
-
validateLoginPasswordFormat(userLoginPassword);
|
|
390
|
+
(0, utils_1.validateLoginPasswordFormat)(userLoginPassword);
|
|
410
391
|
}
|
|
411
392
|
// check the username duplicated?
|
|
412
393
|
const checkUsername = await userModel.list({
|
|
@@ -799,6 +780,23 @@ const UserService = (props) => {
|
|
|
799
780
|
let response = await getUser({ id: Number(updateUserId), includePassword: false, datatypes: [] });
|
|
800
781
|
return response;
|
|
801
782
|
};
|
|
783
|
+
const suspendUsers = async ({ ids }) => {
|
|
784
|
+
if (!ids.length)
|
|
785
|
+
(0, utils_1.throwError)('id is required');
|
|
786
|
+
// change users status
|
|
787
|
+
let response = await userModel.update({
|
|
788
|
+
where: {
|
|
789
|
+
[`${models_1.ModelUserFields.user_id}`]: {
|
|
790
|
+
in: ids.map((i) => Number(i))
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
data: {
|
|
794
|
+
[`${models_1.ModelUserFields.status}`]: false
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
const { login_password, ...safeResponse } = response;
|
|
798
|
+
return safeResponse;
|
|
799
|
+
};
|
|
802
800
|
const getDataTypes = () => {
|
|
803
801
|
let data = [];
|
|
804
802
|
let total = 0;
|
|
@@ -845,6 +843,7 @@ const UserService = (props) => {
|
|
|
845
843
|
updateUser: { fn: updateUser, allowUserTypes: ["operator", "administrator"], actionName: "update user" },
|
|
846
844
|
replacePassword: { fn: replacePassword, allowUserTypes: ["operator", "administrator"], actionName: "replace user password" },
|
|
847
845
|
removeUsers: { fn: removeUsers, allowUserTypes: ["operator", "administrator"], actionName: "remove users" },
|
|
846
|
+
suspendUsers: { fn: suspendUsers, allowUserTypes: ["any"], actionName: "suspend users" },
|
|
848
847
|
getDataTypes: { fn: getDataTypes, allowUserTypes: ["operator", "administrator"], actionName: "get user datatypes" },
|
|
849
848
|
validateUserContact: { fn: validateUserContact, allowUserTypes: ["operator", "administrator"], actionName: "validate user contact" },
|
|
850
849
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/user/UserService.ts"],"names":[],"mappings":";;;AAAA,qCAOkB;AAElB,6BAAwB;AAExB,uDAA0E;AAC1E,uDAAmI;AACnI,iEAAiK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WAAW,eA89BvB","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\";\nimport { CustomerGetProps, CustomerCreateProps, CustomerListProps, CustomerUpdateProps, CustomerService } from \"./CustomerService\";\nimport { AdministratorGetProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorListProps, AdministratorService } from \"./AdministratorService\";\nimport { WorkerCreateProps, WorkerGetProps, WorkerUpdateProps, WorkerListProps, WorkerService } from \"./WorkerService\";\nimport { DriverCreateProps, DriverGetProps, DriverUpdateProps, DriverListProps, DriverService } from \"./DriverService\";\nimport { RetailerCreateProps, RetailerGetProps, RetailerUpdateProps, RetailerListProps, RetailerService } from \"./RetailerService\";\nimport { MemberCreateProps, MemberGetProps, MemberUpdateProps, MemberListProps, MemberService } from \"./MemberService\";\nimport { AgentCreateProps, AgentGetProps, AgentUpdateProps, AgentListProps, AgentService } from \"./AgentService\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { hashPassword } from \"@/utils\";\nimport { OperatorCreateProps, OperatorGetProps, OperatorListProps, OperatorService, OperatorUpdateProps } from \"./OperatorService\";\n\nimport { ServiceFactory } from \"@/lib\";\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 UserServiceProps = DefaultServiceProps & {\n userType: UserType\n};\n\nexport type UserGetProps = QueryGet & {\n id: number,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserGetByUsernameProps = QueryGet & {\n username: string,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n};\n\nexport type UserListProps = QueryList & {\n // id: number,\n includePassword?: boolean\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserRemoveProps = {\n ids: BigInt[]\n};\n\nexport type User = {\n loginUsername: string\n loginPassword: string\n address: string\n // contact: string\n contact: {\n countryCode: number; // e.g., 1 for Canada\n phoneNumber: string; // digits only, mobile or landline\n }\n email: string\n firstname: string\n lastname: string\n status: boolean\n}\n\nexport type UserOptionalLoginPassword = Omit<User, \"loginPassword\"> & {\n loginPassword?: string\n}\n\nexport type UserCreateProps = {\n userType?: UserType,\n data: {\n user: User\n } & (\n // operator\n {\n operator: Omit<OperatorCreateProps[\"data\"][\"operator\"], \"userId\">,\n } |\n // customer\n {\n customer: Omit<CustomerCreateProps[\"data\"][\"customer\"], \"userId\">,\n } |\n // administrator\n {\n administrator: Omit<AdministratorCreateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerCreateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverCreateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberCreateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentCreateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerCreateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserUpdateProps = {\n id: number,\n userType?: UserType,\n data: {\n user: UserOptionalLoginPassword\n } & (\n // operator\n {\n operator: Omit<OperatorUpdateProps[\"data\"][\"operator\"], \"userId\">\n } |\n // customer\n {\n customer: Omit<CustomerUpdateProps[\"data\"][\"customer\"], \"userId\">\n } |\n // administrator\n {\n administrator: Omit<AdministratorUpdateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerUpdateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverUpdateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberUpdateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentUpdateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerUpdateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserReplacePasswordProps = {\n id: number,\n data: {\n unhashLoginPassword: string\n },\n isOperator: boolean\n}\n\nlet mainSqlSelect = {\n [`usr.${ModelUserFields.user_id}`]: \"user_id\",\n [`usr.${ModelUserFields.user_type}`]: \"user_type\",\n [`usr.${ModelUserFields.login_username}`]: \"username\",\n [`usr.${ModelUserFields.firstname}`]: \"firstname\",\n [`usr.${ModelUserFields.lastname}`]: \"lastname\",\n [`CONCAT(usr.${ModelUserFields.contact_country_code}, usr.${ModelUserFields.contact_phone_number})`]: \"contact\",\n [`usr.${ModelUserFields.contact_country_code}`]: \"contact_country_code\",\n [`usr.${ModelUserFields.contact_phone_number}`]: \"contact_phone_number\",\n [`usr.${ModelUserFields.email}`]: \"email\",\n [`usr.${ModelUserFields.address}`]: \"address\",\n [`usr.${ModelUserFields.status}`]: \"status\",\n}\n\nlet defaultSqlSelect = {\n [`usr.${ModelUserFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`usr.${ModelUserFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`usr.${ModelUserFields.isdelete}`]: \"isdelete\",\n [`usr.${ModelUserFields.istrash}`]: \"istrash\",\n [`usr.${ModelUserFields.accountid}`]: \"accountid\",\n}\n\nconst getCreatePayload = async (\n userType: UserType,\n data: UserCreateProps[\"data\"],\n contact: {\n countryCode: number,\n phoneNumber: string\n }\n) => {\n\n if (\"user\" in data) {\n\n // have to hash the password\n\n return {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.login_password}`]: await hashPassword(data.user.loginPassword),\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\nconst getUpdatePayload = async (\n userType: UserType,\n data: UserUpdateProps[\"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\n// Example reserved words for username\nexport const loginUsernameReservedWords = [\n \"admin\", \"administrator\", \"root\", \"system\", \"operator\", \"moderator\", \"owner\", \"manager\",\n \"user\", \"users\", \"account\", \"guest\", \"login\", \"logout\", \"signup\", \"register\", \"auth\",\n \"api\", \"www\", \"app\", \"support\", \"help\", \"dashboard\", \"portal\", \"console\", \"control\", \"ops\",\n \"test\", \"demo\", \"beta\", \"alpha\", \"dev\", \"development\", \"staging\", \"prod\", \"production\",\n \"security\", \"privacy\", \"terms\", \"policy\", \"legal\", \"about\", \"company\", \"team\", \"teams\",\n \"billing\", \"payment\", \"invoice\", \"finance\", \"financeadmin\", \"subscription\", \"plan\", \"plans\",\n \"rootadmin\", \"superuser\", \"staff\", \"moderation\", \"systemadmin\", \"sysadmin\", \"internal\",\n \"management\", \"supportdesk\", \"helpdesk\", \"contact\", \"feedback\", \"news\", \"blog\", \"media\",\n \"press\", \"events\", \"calendar\", \"forum\", \"community\", \"chat\", \"messaging\", \"notifications\",\n \"alerts\", \"reports\", \"analytics\", \"metrics\", \"logs\", \"history\", \"archive\", \"backup\",\n \"restore\", \"files\", \"documents\", \"resources\", \"library\", \"gallery\", \"images\", \"videos\",\n \"downloads\", \"uploads\", \"templates\", \"home\", \"index\", \"static\", \"public\", \"webmaster\"\n];\n\n// Zod schema for username\nexport const loginUsernameSchema = z\n .string()\n .min(5, { message: \"Login username must be at least 5 characters\" })\n .max(63, { message: \"Login username must be at most 63 characters\" })\n .regex(\n /^[a-z0-9]([a-z0-9-_]{3,61}[a-z0-9])?$/,\n \"Login username can only contain lowercase letters, numbers, hyphens, and underscores, cannot start or end with a hyphen or underscore\"\n )\n .transform((val) => val.toLowerCase().trim()) // normalize\n .refine((val) => !loginUsernameReservedWords.includes(val), {\n message: \"This login username is reserved. Please choose another one\",\n });\n\n// Zod schema for password\nexport const loginPasswordSchema = z\n .string()\n .min(8, { message: \"Password must be at least 8 characters\" })\n .max(64, { message: \"Password must be at most 64 characters\" })\n .regex(/[a-zA-Z]/, \"Password must include at least one letter\")\n .regex(/[0-9!@#$%^&*()_\\-+=]/, \"Password must include at least one number or special character\");\n\nexport const UserService = (props: UserServiceProps) => {\n\n const {\n userType = \"administrator\",\n ...rest\n } = props\n\n const userModel = UserModel({ ...rest })\n const countryModel = CountryModel({ ...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 validateUserContactPhoneNumber = (val: string) => {\n // Must be numeric\n if (!/^\\d+$/.test(val)) {\n throw new Error(`Contact No. only allowed numbers`);\n }\n\n // Must have realistic length (4 to 15 digits)\n if (val.length < 4 || val.length > 15) {\n throw new Error(`Contact No. length must be between 4 and 15 digits`);\n }\n\n return true;\n };\n\n const validateUserContactCountryCode = async (countryCode: number) => {\n\n // 1. Load active countries\n const activeCountries: ModelCountry[] = await countryModel.list({\n where: {\n [`${ModelCountryFields.isdelete}`]: false,\n [`${ModelCountryFields.istrash}`]: false,\n [`${ModelCountryFields.status}`]: true\n }\n })\n\n // Check if country code exists\n const exists = activeCountries.some(c => c.phone_code === countryCode);\n\n if (!exists) {\n throw new Error(`Invalid country code: ${countryCode}`);\n }\n\n return true; // valid\n\n }\n\n const validateUserContact = async (countryCode: number, phoneNumber: string) => {\n\n try {\n // validate the phone number without country code\n validateUserContactPhoneNumber(phoneNumber)\n\n // validate user contact country code\n await validateUserContactCountryCode(countryCode)\n\n return true\n\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid user contact no.: ${msg}, provided: ${countryCode} ${phoneNumber}`);\n }\n\n }\n\n const validateLoginUsernameFormat = (loginUsername: string) => {\n try {\n return loginUsernameSchema.parse(loginUsername); // throws if invalid\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new Error(\n `Invalid login username: \"${loginUsername}\". ` +\n err.errors.map((e) => e.message).join(\"; \")\n );\n }\n throw err;\n }\n };\n\n const validateLoginPasswordFormat = (loginPassword: string) => {\n try {\n return loginPasswordSchema.parse(loginPassword); // throws if invalid\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new Error(\n `Invalid login password: \"${loginPassword}\". ` +\n err.errors.map((e) => e.message).join(\"; \")\n );\n }\n throw err;\n }\n };\n\n const createUser = async ({ data, userType: overrideUserType }: UserCreateProps) => {\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 validateLoginPasswordFormat(userLoginPassword)\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.accountid}`]: Number(rest.accountId),\n [`${ModelUserFields.isdelete}`]: false,\n [`${ModelUserFields.istrash}`]: false\n },\n })\n\n // console.log('ch', checkUsername)\n\n if (checkUsername.length > 0) throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n\n // validation before insertion\n if (_userType === \"member\" && \"member\" in data) {\n\n const memberOwnerUserId = data?.member?.ownerUserId ?? \"\";\n\n // validate owner user id\n if (memberOwnerUserId) {\n await memberService.validateMemberOwnerUserId(memberOwnerUserId)\n }\n\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n const agentOwnerUserId = data?.agent?.ownerUserId ?? \"\";\n\n // validate owner user id\n if (agentOwnerUserId) {\n await agentService.validateAgentOwnerUserId(agentOwnerUserId)\n }\n\n }\n\n const _data = await getCreatePayload(\n _userType,\n data,\n {\n countryCode: userContactCountryCode,\n phoneNumber: userContactPhoneNumber\n }\n )\n\n if (!_data) {\n throw new Error(`Invalid create payload: ${JSON.stringify(_data)}`);\n }\n\n // create user\n let responseUser = await userModel.create({ data: _data })\n\n let newUserId = responseUser.user_id\n\n let response: any = {}\n\n if (_userType === \"customer\" && \"customer\" in data) {\n\n let dataCustomer: CustomerCreateProps[\"data\"] = {\n customer: {\n ...data.customer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create customer\n await customerService.createCustomer({ data: dataCustomer })\n\n response = await customerService.getCustomer({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"administrator\" && \"administrator\" in data) {\n\n let dataAdministrator: AdministratorCreateProps[\"data\"] = {\n administrator: {\n ...data.administrator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create administrator\n await administratorService.createAdministrator({ data: dataAdministrator })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await administratorService.getAdministrator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"operator\" && \"operator\" in data) {\n\n let dataOperator: OperatorCreateProps[\"data\"] = {\n operator: {\n ...data.operator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create operator\n await operatorService.createOperator({ data: dataOperator })\n\n response = await operatorService.getOperator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"worker\" && \"worker\" in data) {\n\n let dataWorker: WorkerCreateProps[\"data\"] = {\n worker: {\n ...data.worker,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create worker\n await workerService.createWorker({ data: dataWorker })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await workerService.getWorker({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"driver\" && \"driver\" in data) {\n\n let dataDriver: DriverCreateProps[\"data\"] = {\n driver: {\n ...data.driver,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create driver\n await driverService.createDriver({ data: dataDriver })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await driverService.getDriver({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"member\" && \"member\" in data) {\n\n let dataMember: MemberCreateProps[\"data\"] = {\n member: {\n ...data.member,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create member\n await memberService.createMember({ userId: Number(newUserId), data: dataMember })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await memberService.getMember({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n let dataAgent: AgentCreateProps[\"data\"] = {\n agent: {\n ...data.agent,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create agent\n await agentService.createAgent({ userId: Number(newUserId), data: dataAgent })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await agentService.getAgent({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"retailer\" && \"retailer\" in data) {\n\n let dataRetailer: RetailerCreateProps[\"data\"] = {\n retailer: {\n ...data.retailer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create retailer\n await retailerService.createRetailer({ data: dataRetailer })\n\n response = await retailerService.getRetailer({ id: Number(newUserId), datatypes: [] })\n }\n\n return response\n }\n\n const updateUser = async ({ id, data, userType: overrideUserType }: UserUpdateProps) => {\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.getMember({ 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 getUser = async ({ id, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false, skipFilterUserType = false }: UserGetProps) => {\n\n let data: any = {}\n\n if (skipFilterUserType === true) {\n\n let { data } = await listUsers({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [{ field: \"user_id\", operator: \"=\", value: id }],\n sortfield: \"user_id\",\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId,\n skipFilterUserType\n })\n\n return data[0] ?? null;\n }\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n if (_userType === \"customer\") {\n data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperator({ id, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministrator({ id, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n if (_userType === \"worker\") {\n data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"driver\") {\n data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"member\") {\n data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"agent\") {\n data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"retailer\") {\n data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n }\n\n if (!data) {\n throw new Error(`Invalid id: ${id}`);\n }\n\n return data\n };\n\n const getUserByUsername = async ({ username, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false }: UserGetByUsernameProps) => {\n\n let data: any = {}\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n // if (_userType === \"customer\") {\n // data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperatorByUsername({ username, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministratorByUsername({ username, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n // if (_userType === \"worker\") {\n // data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"driver\") {\n // data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"member\") {\n // data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"agent\") {\n // data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"retailer\") {\n // data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (!data) {\n throw new Error(`Invalid username: ${username}`);\n }\n\n return data\n };\n\n const listUsers = async ({ limit, offset, filters = [], sortfield, sortorder, datatypes, includePassword = false, skipFilterAccountId = false, skipFilterUserType = false }: UserListProps) => {\n\n let data: any[] = [];\n let total = 0;\n\n if (skipFilterUserType === true) {\n\n mainSqlSelect = {\n ...mainSqlSelect,\n ...(includePassword ? { [`usr.${ModelUserFields.login_password}`]: \"password\" } : {}),\n }\n\n let sqlSelect = [\n `COUNT(usr.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"usr\", \"users\", \"creator\", [\"usr.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"usr\", \"users\", \"updater\", [\"usr.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `usr.isdelete = false`,\n `usr.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"users\",\n mainAlias: \"usr\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset,\n skipFilterAccountId\n })\n\n data = await userModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n }\n\n if (userType === \"customer\") {\n ({ data, total } = await customerService.listCustomers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as CustomerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"operator\") {\n ({ data, total } = await operatorService.listOperators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as OperatorListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"administrator\") {\n ({ data, total } = await administratorService.listAdministrators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AdministratorListProps[\"datatypes\"], skipFilterAccountId }\n ))\n }\n\n if (userType === \"worker\") {\n ({ data, total } = await workerService.listWorkers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as WorkerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"driver\") {\n ({ data, total } = await driverService.listDrivers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as DriverListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"member\") {\n ({ data, total } = await memberService.listMembers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as MemberListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"agent\") {\n ({ data, total } = await agentService.listAgents(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AgentListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"retailer\") {\n ({ data, total } = await retailerService.listRetailers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as RetailerListProps[\"datatypes\"] }\n ))\n }\n\n return {\n data,\n total\n }\n };\n\n const removeUsers = async ({ ids }: UserRemoveProps) => {\n\n if (!ids.length) throwError('id is required');\n\n let response: any[] = []\n\n if (userType === \"customer\") {\n response = await customerService.removeCustomers({ userIds: ids })\n }\n\n if (userType === \"operator\") {\n response = await operatorService.removeOperators({ userIds: ids })\n }\n\n if (userType === \"administrator\") {\n\n // have to check the ids is is_owner account\n const { data: administrators } = await administratorService.listAdministrators({\n limit: 9999,\n offset: 0,\n filters: [{\n field: `${ModelAdministratorFields.user_id}`,\n operator: \"where_in\",\n value: ids\n }],\n sortfield: `${ModelAdministratorFields.administrator_id}`,\n sortorder: \"ASC\",\n datatypes: []\n })\n\n const ownerAdministrators = administrators.filter(i => i.is_owner === true)\n\n if (ownerAdministrators.length > 0) {\n throw new Error(`Cannot delete on administrator owner user ids: ${ownerAdministrators.map(i => i.user_id)}`);\n }\n\n response = await administratorService.removeAdministrators({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"worker\") {\n response = await workerService.removeWorkers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"driver\") {\n response = await driverService.removeDrivers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"member\") {\n response = await memberService.removeMembers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"agent\") {\n response = await agentService.removeAgents({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"retailer\") {\n response = await retailerService.removeRetailers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n // remove user\n let responseUser = await userModel.remove({ ids: ids.map(i => Number(i)) })\n\n response.forEach((i, index) => {\n i.user = responseUser[index]\n })\n\n return response\n };\n\n const replacePassword = async ({ id, data, isOperator = false }: UserReplacePasswordProps) => {\n\n const passwordUserModel = UserModel({\n ...rest,\n ...(isOperator === true ? { isOperator } : {})\n })\n\n // update user password\n let responseUser = await passwordUserModel.update({\n id,\n data: {\n login_password: await hashPassword(data?.unhashLoginPassword)\n }\n })\n\n let updateUserId = responseUser.user_id\n\n let response = await getUser({ id: Number(updateUserId), includePassword: false, datatypes: [] })\n\n return response\n }\n\n const getDataTypes = () => {\n\n let data: any[] = [];\n let total = 0;\n\n if (userType === \"customer\") {\n data = customerService.getDataTypes()\n }\n\n if (userType === \"operator\") {\n data = operatorService.getDataTypes()\n }\n\n if (userType === \"administrator\") {\n data = administratorService.getDataTypes()\n }\n\n if (userType === \"worker\") {\n data = workerService.getDataTypes()\n }\n\n if (userType === \"driver\") {\n data = driverService.getDataTypes()\n }\n\n if (userType === \"member\") {\n data = memberService.getDataTypes()\n }\n\n if (userType === \"agent\") {\n data = agentService.getDataTypes()\n }\n\n if (userType === \"retailer\") {\n data = retailerService.getDataTypes()\n }\n\n return data\n };\n\n // return {\n // createUser,\n // updateUser,\n // getUser,\n // listUsers,\n // removeUsers,\n // replacePassword,\n // getUserDataTypes\n // }\n\n const methodConfigs = {\n getUser: { fn: getUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user\" },\n getUserByUsername: { fn: getUserByUsername, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user by username\" },\n listUsers: { fn: listUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"list users\" },\n createUser: { fn: createUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"create user\" },\n updateUser: { fn: updateUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"update user\" },\n replacePassword: { fn: replacePassword, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"replace user password\" },\n removeUsers: { fn: removeUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"remove users\" },\n getDataTypes: { fn: getDataTypes, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user datatypes\" },\n validateUserContact: { fn: validateUserContact, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"validate user contact\" },\n };\n\n return ServiceFactory(\"UserService\", rest, methodConfigs);\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/user/UserService.ts"],"names":[],"mappings":";;;AAAA,qCAOkB;AAElB,6BAAwB;AAExB,uDAA0E;AAC1E,uDAAmI;AACnI,iEAAiK;AACjK,mDAAuH;AACvH,mDAAuH;AACvH,uDAAmI;AACnI,mDAAuH;AACvH,iDAAiH;AAGjH,+BAAgK;AAEhK,mCAAuF;AAEvF,mCAAuC;AACvC,uDAAmI;AAEnI,+BAAuC;AAE1B,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,EAAE,OAAO;CACR,CAAA;AAsLV,IAAI,aAAa,GAAG;IAChB,CAAC,OAAO,wBAAe,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS;IAC7C,CAAC,OAAO,wBAAe,CAAC,SAAS,EAAE,CAAC,EAAE,WAAW;IACjD,CAAC,OAAO,wBAAe,CAAC,cAAc,EAAE,CAAC,EAAE,UAAU;IACrD,CAAC,OAAO,wBAAe,CAAC,SAAS,E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Ae,CAAU,EAAE,UAAU,EAAE,cAAc,EAAE;QACpH,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,KAAK,CAAU,EAAE,UAAU,EAAE,eAAe,EAAE;QACjG,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE;QAC5H,mBAAmB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,uBAAuB,EAAE;KAChJ,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,aAAa,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAE9D,CAAC,CAAA;AAt+BY,QAAA,WAAW,eAs+BvB","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\";\nimport { CustomerGetProps, CustomerCreateProps, CustomerListProps, CustomerUpdateProps, CustomerService } from \"./CustomerService\";\nimport { AdministratorGetProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorListProps, AdministratorService } from \"./AdministratorService\";\nimport { WorkerCreateProps, WorkerGetProps, WorkerUpdateProps, WorkerListProps, WorkerService } from \"./WorkerService\";\nimport { DriverCreateProps, DriverGetProps, DriverUpdateProps, DriverListProps, DriverService } from \"./DriverService\";\nimport { RetailerCreateProps, RetailerGetProps, RetailerUpdateProps, RetailerListProps, RetailerService } from \"./RetailerService\";\nimport { MemberCreateProps, MemberGetProps, MemberUpdateProps, MemberListProps, MemberService } from \"./MemberService\";\nimport { AgentCreateProps, AgentGetProps, AgentUpdateProps, AgentListProps, AgentService } from \"./AgentService\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { hashPassword } from \"@/utils\";\nimport { OperatorCreateProps, OperatorGetProps, OperatorListProps, OperatorService, OperatorUpdateProps } from \"./OperatorService\";\n\nimport { ServiceFactory } from \"@/lib\";\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 UserServiceProps = DefaultServiceProps & {\n userType: UserType\n};\n\nexport type UserGetProps = QueryGet & {\n id: number,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserGetByUsernameProps = QueryGet & {\n username: string,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n};\n\nexport type UserListProps = QueryList & {\n // id: number,\n includePassword?: boolean\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserRemoveProps = {\n ids: BigInt[]\n};\n\nexport type UserSuspendProps = {\n ids: BigInt[]\n};\n\nexport type User = {\n loginUsername: string\n loginPassword: string\n address: string\n // contact: string\n contact: {\n countryCode: number; // e.g., 1 for Canada\n phoneNumber: string; // digits only, mobile or landline\n }\n email: string\n firstname: string\n lastname: string\n status: boolean\n}\n\nexport type UserOptionalLoginPassword = Omit<User, \"loginPassword\"> & {\n loginPassword?: string\n}\n\nexport type UserCreateProps = {\n userType?: UserType,\n data: {\n user: User\n } & (\n // operator\n {\n operator: Omit<OperatorCreateProps[\"data\"][\"operator\"], \"userId\">,\n } |\n // customer\n {\n customer: Omit<CustomerCreateProps[\"data\"][\"customer\"], \"userId\">,\n } |\n // administrator\n {\n administrator: Omit<AdministratorCreateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerCreateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverCreateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberCreateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentCreateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerCreateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserUpdateProps = {\n id: number,\n userType?: UserType,\n data: {\n user: UserOptionalLoginPassword\n } & (\n // operator\n {\n operator: Omit<OperatorUpdateProps[\"data\"][\"operator\"], \"userId\">\n } |\n // customer\n {\n customer: Omit<CustomerUpdateProps[\"data\"][\"customer\"], \"userId\">\n } |\n // administrator\n {\n administrator: Omit<AdministratorUpdateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerUpdateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverUpdateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberUpdateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentUpdateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerUpdateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserReplacePasswordProps = {\n id: number,\n data: {\n unhashLoginPassword: string\n },\n isOperator: boolean\n}\n\nlet mainSqlSelect = {\n [`usr.${ModelUserFields.user_id}`]: \"user_id\",\n [`usr.${ModelUserFields.user_type}`]: \"user_type\",\n [`usr.${ModelUserFields.login_username}`]: \"username\",\n [`usr.${ModelUserFields.firstname}`]: \"firstname\",\n [`usr.${ModelUserFields.lastname}`]: \"lastname\",\n [`CONCAT(usr.${ModelUserFields.contact_country_code}, usr.${ModelUserFields.contact_phone_number})`]: \"contact\",\n [`usr.${ModelUserFields.contact_country_code}`]: \"contact_country_code\",\n [`usr.${ModelUserFields.contact_phone_number}`]: \"contact_phone_number\",\n [`usr.${ModelUserFields.email}`]: \"email\",\n [`usr.${ModelUserFields.address}`]: \"address\",\n [`usr.${ModelUserFields.status}`]: \"status\",\n}\n\nlet defaultSqlSelect = {\n [`usr.${ModelUserFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`usr.${ModelUserFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`usr.${ModelUserFields.isdelete}`]: \"isdelete\",\n [`usr.${ModelUserFields.istrash}`]: \"istrash\",\n [`usr.${ModelUserFields.accountid}`]: \"accountid\",\n}\n\nconst getCreatePayload = async (\n userType: UserType,\n data: UserCreateProps[\"data\"],\n contact: {\n countryCode: number,\n phoneNumber: string\n }\n) => {\n\n if (\"user\" in data) {\n\n // have to hash the password\n\n return {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.login_password}`]: await hashPassword(data.user.loginPassword),\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\nconst getUpdatePayload = async (\n userType: UserType,\n data: UserUpdateProps[\"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\n// Example reserved words for username\nexport const loginUsernameReservedWords = [\n \"admin\", \"administrator\", \"root\", \"system\", \"operator\", \"moderator\", \"owner\", \"manager\",\n \"user\", \"users\", \"account\", \"guest\", \"login\", \"logout\", \"signup\", \"register\", \"auth\",\n \"api\", \"www\", \"app\", \"support\", \"help\", \"dashboard\", \"portal\", \"console\", \"control\", \"ops\",\n \"test\", \"demo\", \"beta\", \"alpha\", \"dev\", \"development\", \"staging\", \"prod\", \"production\",\n \"security\", \"privacy\", \"terms\", \"policy\", \"legal\", \"about\", \"company\", \"team\", \"teams\",\n \"billing\", \"payment\", \"invoice\", \"finance\", \"financeadmin\", \"subscription\", \"plan\", \"plans\",\n \"rootadmin\", \"superuser\", \"staff\", \"moderation\", \"systemadmin\", \"sysadmin\", \"internal\",\n \"management\", \"supportdesk\", \"helpdesk\", \"contact\", \"feedback\", \"news\", \"blog\", \"media\",\n \"press\", \"events\", \"calendar\", \"forum\", \"community\", \"chat\", \"messaging\", \"notifications\",\n \"alerts\", \"reports\", \"analytics\", \"metrics\", \"logs\", \"history\", \"archive\", \"backup\",\n \"restore\", \"files\", \"documents\", \"resources\", \"library\", \"gallery\", \"images\", \"videos\",\n \"downloads\", \"uploads\", \"templates\", \"home\", \"index\", \"static\", \"public\", \"webmaster\"\n];\n\n// Zod schema for username\nexport const loginUsernameSchema = z\n .string()\n .min(5, { message: \"Login username must be at least 5 characters\" })\n .max(63, { message: \"Login username must be at most 63 characters\" })\n .regex(\n /^[a-z0-9]([a-z0-9-_]{3,61}[a-z0-9])?$/,\n \"Login username can only contain lowercase letters, numbers, hyphens, and underscores, cannot start or end with a hyphen or underscore\"\n )\n .transform((val) => val.toLowerCase().trim()) // normalize\n .refine((val) => !loginUsernameReservedWords.includes(val), {\n message: \"This login username is reserved. Please choose another one\",\n });\n\nexport const UserService = (props: UserServiceProps) => {\n\n const {\n userType = \"administrator\",\n ...rest\n } = props\n\n const userModel = UserModel({ ...rest })\n const countryModel = CountryModel({ ...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 validateUserContactPhoneNumber = (val: string) => {\n // Must be numeric\n if (!/^\\d+$/.test(val)) {\n throw new Error(`Contact No. only allowed numbers`);\n }\n\n // Must have realistic length (4 to 15 digits)\n if (val.length < 4 || val.length > 15) {\n throw new Error(`Contact No. length must be between 4 and 15 digits`);\n }\n\n return true;\n };\n\n const validateUserContactCountryCode = async (countryCode: number) => {\n\n // 1. Load active countries\n const activeCountries: ModelCountry[] = await countryModel.list({\n where: {\n [`${ModelCountryFields.isdelete}`]: false,\n [`${ModelCountryFields.istrash}`]: false,\n [`${ModelCountryFields.status}`]: true\n }\n })\n\n // Check if country code exists\n const exists = activeCountries.some(c => c.phone_code === countryCode);\n\n if (!exists) {\n throw new Error(`Invalid country code: ${countryCode}`);\n }\n\n return true; // valid\n\n }\n\n const validateUserContact = async (countryCode: number, phoneNumber: string) => {\n\n try {\n // validate the phone number without country code\n validateUserContactPhoneNumber(phoneNumber)\n\n // validate user contact country code\n await validateUserContactCountryCode(countryCode)\n\n return true\n\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid user contact no.: ${msg}, provided: ${countryCode} ${phoneNumber}`);\n }\n\n }\n\n const validateLoginUsernameFormat = (loginUsername: string) => {\n try {\n return loginUsernameSchema.parse(loginUsername); // throws if invalid\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new Error(\n `Invalid login username: \"${loginUsername}\". ` +\n err.errors.map((e) => e.message).join(\"; \")\n );\n }\n throw err;\n }\n };\n\n const createUser = async ({ data, userType: overrideUserType }: UserCreateProps) => {\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 validateLoginPasswordFormat(userLoginPassword)\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.accountid}`]: Number(rest.accountId),\n [`${ModelUserFields.isdelete}`]: false,\n [`${ModelUserFields.istrash}`]: false\n },\n })\n\n // console.log('ch', checkUsername)\n\n if (checkUsername.length > 0) throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n\n // validation before insertion\n if (_userType === \"member\" && \"member\" in data) {\n\n const memberOwnerUserId = data?.member?.ownerUserId ?? \"\";\n\n // validate owner user id\n if (memberOwnerUserId) {\n await memberService.validateMemberOwnerUserId(memberOwnerUserId)\n }\n\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n const agentOwnerUserId = data?.agent?.ownerUserId ?? \"\";\n\n // validate owner user id\n if (agentOwnerUserId) {\n await agentService.validateAgentOwnerUserId(agentOwnerUserId)\n }\n\n }\n\n const _data = await getCreatePayload(\n _userType,\n data,\n {\n countryCode: userContactCountryCode,\n phoneNumber: userContactPhoneNumber\n }\n )\n\n if (!_data) {\n throw new Error(`Invalid create payload: ${JSON.stringify(_data)}`);\n }\n\n // create user\n let responseUser = await userModel.create({ data: _data })\n\n let newUserId = responseUser.user_id\n\n let response: any = {}\n\n if (_userType === \"customer\" && \"customer\" in data) {\n\n let dataCustomer: CustomerCreateProps[\"data\"] = {\n customer: {\n ...data.customer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create customer\n await customerService.createCustomer({ data: dataCustomer })\n\n response = await customerService.getCustomer({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"administrator\" && \"administrator\" in data) {\n\n let dataAdministrator: AdministratorCreateProps[\"data\"] = {\n administrator: {\n ...data.administrator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create administrator\n await administratorService.createAdministrator({ data: dataAdministrator })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await administratorService.getAdministrator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"operator\" && \"operator\" in data) {\n\n let dataOperator: OperatorCreateProps[\"data\"] = {\n operator: {\n ...data.operator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create operator\n await operatorService.createOperator({ data: dataOperator })\n\n response = await operatorService.getOperator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"worker\" && \"worker\" in data) {\n\n let dataWorker: WorkerCreateProps[\"data\"] = {\n worker: {\n ...data.worker,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create worker\n await workerService.createWorker({ data: dataWorker })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await workerService.getWorker({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"driver\" && \"driver\" in data) {\n\n let dataDriver: DriverCreateProps[\"data\"] = {\n driver: {\n ...data.driver,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create driver\n await driverService.createDriver({ data: dataDriver })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await driverService.getDriver({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"member\" && \"member\" in data) {\n\n let dataMember: MemberCreateProps[\"data\"] = {\n member: {\n ...data.member,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create member\n await memberService.createMember({ userId: Number(newUserId), data: dataMember })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await memberService.getMember({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n let dataAgent: AgentCreateProps[\"data\"] = {\n agent: {\n ...data.agent,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create agent\n await agentService.createAgent({ userId: Number(newUserId), data: dataAgent })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await agentService.getAgent({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"retailer\" && \"retailer\" in data) {\n\n let dataRetailer: RetailerCreateProps[\"data\"] = {\n retailer: {\n ...data.retailer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create retailer\n await retailerService.createRetailer({ data: dataRetailer })\n\n response = await retailerService.getRetailer({ id: Number(newUserId), datatypes: [] })\n }\n\n return response\n }\n\n const updateUser = async ({ id, data, userType: overrideUserType }: UserUpdateProps) => {\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.getMember({ 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 getUser = async ({ id, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false, skipFilterUserType = false }: UserGetProps) => {\n\n let data: any = {}\n\n if (skipFilterUserType === true) {\n\n let { data } = await listUsers({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [{ field: \"user_id\", operator: \"=\", value: id }],\n sortfield: \"user_id\",\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId,\n skipFilterUserType\n })\n\n return data[0] ?? null;\n }\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n if (_userType === \"customer\") {\n data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperator({ id, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministrator({ id, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n if (_userType === \"worker\") {\n data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"driver\") {\n data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"member\") {\n data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"agent\") {\n data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"retailer\") {\n data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n }\n\n if (!data) {\n throw new Error(`Invalid id: ${id}`);\n }\n\n return data\n };\n\n const getUserByUsername = async ({ username, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false }: UserGetByUsernameProps) => {\n\n let data: any = {}\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n // if (_userType === \"customer\") {\n // data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperatorByUsername({ username, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministratorByUsername({ username, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n // if (_userType === \"worker\") {\n // data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"driver\") {\n // data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"member\") {\n // data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"agent\") {\n // data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"retailer\") {\n // data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (!data) {\n throw new Error(`Invalid username: ${username}`);\n }\n\n return data\n };\n\n const listUsers = async ({ limit, offset, filters = [], sortfield, sortorder, datatypes, includePassword = false, skipFilterAccountId = false, skipFilterUserType = false }: UserListProps) => {\n\n let data: any[] = [];\n let total = 0;\n\n if (skipFilterUserType === true) {\n\n mainSqlSelect = {\n ...mainSqlSelect,\n ...(includePassword ? { [`usr.${ModelUserFields.login_password}`]: \"password\" } : {}),\n }\n\n let sqlSelect = [\n `COUNT(usr.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"usr\", \"users\", \"creator\", [\"usr.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"usr\", \"users\", \"updater\", [\"usr.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `usr.isdelete = false`,\n `usr.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"users\",\n mainAlias: \"usr\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset,\n skipFilterAccountId\n })\n\n data = await userModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n }\n\n if (userType === \"customer\") {\n ({ data, total } = await customerService.listCustomers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as CustomerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"operator\") {\n ({ data, total } = await operatorService.listOperators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as OperatorListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"administrator\") {\n ({ data, total } = await administratorService.listAdministrators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AdministratorListProps[\"datatypes\"], skipFilterAccountId }\n ))\n }\n\n if (userType === \"worker\") {\n ({ data, total } = await workerService.listWorkers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as WorkerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"driver\") {\n ({ data, total } = await driverService.listDrivers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as DriverListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"member\") {\n ({ data, total } = await memberService.listMembers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as MemberListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"agent\") {\n ({ data, total } = await agentService.listAgents(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AgentListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"retailer\") {\n ({ data, total } = await retailerService.listRetailers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as RetailerListProps[\"datatypes\"] }\n ))\n }\n\n return {\n data,\n total\n }\n };\n\n const removeUsers = async ({ ids }: UserRemoveProps) => {\n\n if (!ids.length) throwError('id is required');\n\n let response: any[] = []\n\n if (userType === \"customer\") {\n response = await customerService.removeCustomers({ userIds: ids })\n }\n\n if (userType === \"operator\") {\n response = await operatorService.removeOperators({ userIds: ids })\n }\n\n if (userType === \"administrator\") {\n\n // have to check the ids is is_owner account\n const { data: administrators } = await administratorService.listAdministrators({\n limit: 9999,\n offset: 0,\n filters: [{\n field: `${ModelAdministratorFields.user_id}`,\n operator: \"where_in\",\n value: ids\n }],\n sortfield: `${ModelAdministratorFields.administrator_id}`,\n sortorder: \"ASC\",\n datatypes: []\n })\n\n const ownerAdministrators = administrators.filter(i => i.is_owner === true)\n\n if (ownerAdministrators.length > 0) {\n throw new Error(`Cannot delete on administrator owner user ids: ${ownerAdministrators.map(i => i.user_id)}`);\n }\n\n response = await administratorService.removeAdministrators({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"worker\") {\n response = await workerService.removeWorkers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"driver\") {\n response = await driverService.removeDrivers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"member\") {\n response = await memberService.removeMembers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"agent\") {\n response = await agentService.removeAgents({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"retailer\") {\n response = await retailerService.removeRetailers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n // remove user\n let responseUser = await userModel.remove({ ids: ids.map(i => Number(i)) })\n\n response.forEach((i, index) => {\n i.user = responseUser[index]\n })\n\n return response\n };\n\n const replacePassword = async ({ id, data, isOperator = false }: UserReplacePasswordProps) => {\n\n const passwordUserModel = UserModel({\n ...rest,\n ...(isOperator === true ? { isOperator } : {})\n })\n\n // update user password\n let responseUser = await passwordUserModel.update({\n id,\n data: {\n login_password: await hashPassword(data?.unhashLoginPassword)\n }\n })\n\n let updateUserId = responseUser.user_id\n\n let response = await getUser({ id: Number(updateUserId), includePassword: false, datatypes: [] })\n\n return response\n }\n\n const suspendUsers = async ({ ids }: UserSuspendProps) => {\n\n if (!ids.length) throwError('id is required');\n\n // change users status\n let response = await userModel.update({\n where: {\n [`${ModelUserFields.user_id}`]: {\n in: ids.map((i: any) => Number(i))\n }\n },\n data: {\n [`${ModelUserFields.status}`]: false\n }\n })\n\n const { login_password, ...safeResponse } = response;\n\n return safeResponse\n };\n\n const getDataTypes = () => {\n\n let data: any[] = [];\n let total = 0;\n\n if (userType === \"customer\") {\n data = customerService.getDataTypes()\n }\n\n if (userType === \"operator\") {\n data = operatorService.getDataTypes()\n }\n\n if (userType === \"administrator\") {\n data = administratorService.getDataTypes()\n }\n\n if (userType === \"worker\") {\n data = workerService.getDataTypes()\n }\n\n if (userType === \"driver\") {\n data = driverService.getDataTypes()\n }\n\n if (userType === \"member\") {\n data = memberService.getDataTypes()\n }\n\n if (userType === \"agent\") {\n data = agentService.getDataTypes()\n }\n\n if (userType === \"retailer\") {\n data = retailerService.getDataTypes()\n }\n\n return data\n };\n\n // return {\n // createUser,\n // updateUser,\n // getUser,\n // listUsers,\n // removeUsers,\n // replacePassword,\n // getUserDataTypes\n // }\n\n const methodConfigs = {\n getUser: { fn: getUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user\" },\n getUserByUsername: { fn: getUserByUsername, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user by username\" },\n listUsers: { fn: listUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"list users\" },\n createUser: { fn: createUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"create user\" },\n updateUser: { fn: updateUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"update user\" },\n replacePassword: { fn: replacePassword, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"replace user password\" },\n removeUsers: { fn: removeUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"remove users\" },\n suspendUsers: { fn: suspendUsers, allowUserTypes: [\"any\"] as const, actionName: \"suspend users\" },\n getDataTypes: { fn: getDataTypes, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user datatypes\" },\n validateUserContact: { fn: validateUserContact, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"validate user contact\" },\n };\n\n return ServiceFactory(\"UserService\", rest, methodConfigs);\n\n}\n\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DefaultServiceProps } from "../../../utils";
|
|
2
|
+
export type ChangePasswordUtilServiceProps = DefaultServiceProps & {
|
|
3
|
+
secretKey: string;
|
|
4
|
+
};
|
|
5
|
+
export type ChangePasswordUtilChangeProps = {
|
|
6
|
+
authToken: string;
|
|
7
|
+
currentPassword: string;
|
|
8
|
+
newPassword: string;
|
|
9
|
+
confirmPassword: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ChangePasswordUtilService: (props: ChangePasswordUtilServiceProps) => {
|
|
12
|
+
changePassword: ({ authToken, currentPassword, confirmPassword, newPassword }: ChangePasswordUtilChangeProps) => Promise<any>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangePasswordUtilService = void 0;
|
|
4
|
+
const utils_1 = require("../../../utils");
|
|
5
|
+
const services_1 = require("../../../services");
|
|
6
|
+
// import { config } from "../../../configs/config";
|
|
7
|
+
const utils_2 = require("../../../utils");
|
|
8
|
+
const ChangePasswordUtilService = (props) => {
|
|
9
|
+
const { secretKey, ...rest } = props;
|
|
10
|
+
const changePassword = async ({ authToken, currentPassword, confirmPassword, newPassword }) => {
|
|
11
|
+
// retrive core configuration
|
|
12
|
+
const coreConfig = (0, utils_1.getCoreConfiguration)();
|
|
13
|
+
// const authSecretKey = config.AUTH_SECRET_KEY
|
|
14
|
+
const authSecretKey = coreConfig.authSecretKey;
|
|
15
|
+
// validate the token
|
|
16
|
+
const jwtData = (0, utils_2.verifyAuthToken)(authToken, authSecretKey);
|
|
17
|
+
const accountId = jwtData?.account?.account_id ?? "";
|
|
18
|
+
const userId = jwtData?.user?.user_id ?? "";
|
|
19
|
+
const userType = jwtData?.user?.user_type ?? "";
|
|
20
|
+
if (!accountId && userType !== "operator") { // operator token do not have account id
|
|
21
|
+
(0, utils_1.throwError)(`Invalid or missing account id in auth token`);
|
|
22
|
+
}
|
|
23
|
+
if (!userId) {
|
|
24
|
+
(0, utils_1.throwError)(`Missing user id in auth token`);
|
|
25
|
+
}
|
|
26
|
+
if (!userType) {
|
|
27
|
+
(0, utils_1.throwError)(`Missing user type in auth token`);
|
|
28
|
+
}
|
|
29
|
+
const userService = (0, services_1.UserService)({ userType, ...rest });
|
|
30
|
+
const accountService = (0, services_1.AccountService)({ ...rest, isOperator: true });
|
|
31
|
+
const user = await userService.getUser({ id: Number(userId), datatypes: [], includePassword: true });
|
|
32
|
+
const account = await accountService.getAccount({ id: Number(accountId), datatypes: [] });
|
|
33
|
+
// console.log('jwtData', jwtData)
|
|
34
|
+
// console.log('user', user)
|
|
35
|
+
// console.log('account', account)
|
|
36
|
+
// const a = await hashPassword(user?.password)
|
|
37
|
+
// check the accountId / userId is valid
|
|
38
|
+
if (!user?.user_id) {
|
|
39
|
+
(0, utils_1.throwError)(`Invalid user id in auth token`);
|
|
40
|
+
}
|
|
41
|
+
if (Object.keys(account).length <= 0) { // must have account id record
|
|
42
|
+
(0, utils_1.throwError)(`Invalid account id in auth token`);
|
|
43
|
+
}
|
|
44
|
+
// new password cannot same with current password
|
|
45
|
+
if (newPassword === currentPassword) {
|
|
46
|
+
(0, utils_1.throwError)(`New and current password cannot be same`);
|
|
47
|
+
}
|
|
48
|
+
// new password must same with confirm
|
|
49
|
+
if (newPassword !== confirmPassword) {
|
|
50
|
+
(0, utils_1.throwError)(`New and confirm password not matched`);
|
|
51
|
+
}
|
|
52
|
+
// check the current password
|
|
53
|
+
try {
|
|
54
|
+
const decryptedPass = await (0, utils_2.verifyPassword)(currentPassword, user?.password);
|
|
55
|
+
// console.log('decryptedPass', decryptedPass)
|
|
56
|
+
if (!decryptedPass) {
|
|
57
|
+
throw Error(`Invalid current password`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
(0, utils_1.throwError)(`Auth Token: ${error?.message}`);
|
|
62
|
+
}
|
|
63
|
+
// perform update credential
|
|
64
|
+
const responseUser = await userService.replacePassword({
|
|
65
|
+
id: Number(userId),
|
|
66
|
+
data: {
|
|
67
|
+
unhashLoginPassword: newPassword
|
|
68
|
+
},
|
|
69
|
+
isOperator: Boolean(userType === "operator")
|
|
70
|
+
});
|
|
71
|
+
return responseUser;
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
changePassword
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.ChangePasswordUtilService = ChangePasswordUtilService;
|
|
78
|
+
//# sourceMappingURL=ChangePasswordUtilService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangePasswordUtilService.js","sourceRoot":"","sources":["../../../../src/services/utils/unuse/ChangePasswordUtilService.ts"],"names":[],"mappings":";;;AAAA,mCAAgF;AAChF,yCAGoB;AAEpB,6CAA6C;AAE7C,mCAAuE;AAahE,MAAM,yBAAyB,GAAG,CAAC,KAAqC,EAAE,EAAE;IAE/E,MAAM,EACF,SAAS,EACT,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAiC,EAAE,EAAE;QAEzH,6BAA6B;QAC7B,MAAM,UAAU,GAAG,IAAA,4BAAoB,GAAE,CAAA;QAEzC,+CAA+C;QAC/C,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,CAAA;QAE9C,qBAAqB;QACrB,MAAM,OAAO,GAAG,IAAA,uBAAe,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE1D,MAAM,SAAS,GAAG,OAAO,EAAE,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC;QAEhD,IAAI,CAAC,SAAS,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC,CAAC,wCAAwC;YACjF,IAAA,kBAAU,EAAC,6CAA6C,CAAC,CAAA;QAC7D,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,IAAA,kBAAU,EAAC,+BAA+B,CAAC,CAAA;QAC/C,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,IAAA,kBAAU,EAAC,iCAAiC,CAAC,CAAA;QACjD,CAAC;QAED,MAAM,WAAW,GAAG,IAAA,sBAAW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A0B,CAAC,CAAA;YAC3C,CAAC;QAEL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,IAAA,kBAAU,EAAC,eAAe,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/C,CAAC;QAED,4BAA4B;QAC5B,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,eAAe,CAAC;YACnD,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC;YAClB,IAAI,EAAE;gBACF,mBAAmB,EAAE,WAAW;aACnC;YACD,UAAU,EAAE,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC;SAC/C,CAAC,CAAA;QAEF,OAAO,YAAY,CAAA;IAEvB,CAAC,CAAA;IAED,OAAO;QACH,cAAc;KACjB,CAAA;AAEL,CAAC,CAAA;AA/FY,QAAA,yBAAyB,6BA+FrC","sourcesContent":["import { DefaultServiceProps, getCoreConfiguration, throwError } from \"@/utils\";\nimport {\n UserService,\n AccountService,\n} from \"@/services\";\n\n// import { config } from \"@/configs/config\";\n\nimport { verifyPassword, verifyAuthToken, hashPassword } from \"@/utils\"\n\nexport type ChangePasswordUtilServiceProps = DefaultServiceProps & {\n secretKey: string,\n};\n\nexport type ChangePasswordUtilChangeProps = {\n authToken: string,\n currentPassword: string\n newPassword: string\n confirmPassword: string\n};\n\nexport const ChangePasswordUtilService = (props: ChangePasswordUtilServiceProps) => {\n\n const {\n secretKey,\n ...rest\n } = props\n\n const changePassword = async ({ authToken, currentPassword, confirmPassword, newPassword }: ChangePasswordUtilChangeProps) => {\n\n // retrive core configuration\n const coreConfig = getCoreConfiguration()\n\n // const authSecretKey = config.AUTH_SECRET_KEY\n const authSecretKey = coreConfig.authSecretKey\n\n // validate the token\n const jwtData = verifyAuthToken(authToken, authSecretKey);\n\n const accountId = jwtData?.account?.account_id ?? \"\";\n const userId = jwtData?.user?.user_id ?? \"\";\n const userType = jwtData?.user?.user_type ?? \"\";\n\n if (!accountId && userType !== \"operator\") { // operator token do not have account id\n throwError(`Invalid or missing account id in auth token`)\n }\n\n if (!userId) {\n throwError(`Missing user id in auth token`)\n }\n\n if (!userType) {\n throwError(`Missing user type in auth token`)\n }\n\n const userService = UserService({ userType, ...rest })\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('jwtData', jwtData)\n // console.log('user', user)\n // console.log('account', account)\n\n // const a = await hashPassword(user?.password)\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 // 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 return {\n changePassword\n }\n\n}\n\n"]}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export { getDefaultServiceProps, generateServiceProps } from "./serviceUtils";
|
|
|
12
12
|
export { buildFullFieldName, groupPayloadInjectionFields } from "./injectionFieldUtils";
|
|
13
13
|
export { generateAuthToken, verifyAuthToken } from "./authUtils";
|
|
14
14
|
export { generateAccessKeyId, generateAccessKeySecret, hashAccessKeySecret, encryptAccessKeySecret, decryptAccessKeySecret } from "./accessKeyUtils";
|
|
15
|
-
export { hashPassword, verifyPassword } from "./passwordUtils";
|
|
15
|
+
export { loginPasswordFormatSchema, validateLoginPasswordFormat, hashPassword, verifyPassword } from "./passwordUtils";
|
|
16
16
|
export { generateFileThumbnailBuffer } from "./fileThumbnail";
|
|
17
17
|
export { validateFormatEmailAddress, validateFormatMobileNumber } from "./validateFormatUtils";
|