my-typescript-library-rahul52us 1.3.4 → 1.3.5
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/config/auth/passportConfig.js +3 -2
- package/dist/config/auth/passportConfig.js.map +1 -1
- package/dist/controllers/auth.controller.js +1 -1
- package/dist/controllers/auth.controller.js.map +1 -1
- package/dist/controllers/rbac/rbac.controller.js +1 -5
- package/dist/controllers/rbac/rbac.controller.js.map +1 -1
- package/dist/helpers/jwt.helper.js +1 -1
- package/dist/helpers/jwt.helper.js.map +1 -1
- package/dist/libs/mail.js +1 -1
- package/dist/libs/mail.js.map +1 -1
- package/dist/repository/accountdetails.repository.js +1 -1
- package/dist/repository/accountdetails.repository.js.map +1 -1
- package/dist/repository/document.repository.js +175 -23
- package/dist/repository/document.repository.js.map +1 -1
- package/dist/repository/filesystem.repository.js +3 -3
- package/dist/repository/filesystem.repository.js.map +1 -1
- package/dist/repository/log.repository.js +3 -3
- package/dist/repository/log.repository.js.map +1 -1
- package/dist/repository/notifications.repository.js.map +1 -1
- package/dist/repository/schemas/accountdetails.schema.js.map +1 -1
- package/dist/repository/schemas/accounts.schema.js +10 -33
- package/dist/repository/schemas/accounts.schema.js.map +1 -1
- package/dist/repository/schemas/document.schema.js +12 -19
- package/dist/repository/schemas/document.schema.js.map +1 -1
- package/dist/repository/schemas/extracted.schema.js +3 -5
- package/dist/repository/schemas/extracted.schema.js.map +1 -1
- package/dist/repository/schemas/fileSystem.schema.js +2 -5
- package/dist/repository/schemas/fileSystem.schema.js.map +1 -1
- package/dist/repository/schemas/form.schema.js +1 -1
- package/dist/repository/schemas/form.schema.js.map +1 -1
- package/dist/repository/schemas/log.schema.js +4 -4
- package/dist/repository/schemas/log.schema.js.map +1 -1
- package/dist/repository/schemas/notifications.schema.js +2 -3
- package/dist/repository/schemas/notifications.schema.js.map +1 -1
- package/dist/repository/schemas/organisation.schema.js +25 -29
- package/dist/repository/schemas/organisation.schema.js.map +1 -1
- package/dist/repository/schemas/profile.schema.js +1 -1
- package/dist/repository/schemas/profile.schema.js.map +1 -1
- package/dist/repository/schemas/role.schema.js +1 -1
- package/dist/repository/schemas/role.schema.js.map +1 -1
- package/dist/repository/schemas/tokens.schema.js +5 -5
- package/dist/repository/schemas/tokens.schema.js.map +1 -1
- package/dist/repository/schemas/userrole.schema.js +1 -1
- package/dist/repository/schemas/userrole.schema.js.map +1 -1
- package/dist/repository/schemas/workflow.schema.js +14 -40
- package/dist/repository/schemas/workflow.schema.js.map +1 -1
- package/dist/repository/user.repository.js +32 -20
- package/dist/repository/user.repository.js.map +1 -1
- package/dist/repository/user_tokens.repository.js +1 -1
- package/dist/repository/user_tokens.repository.js.map +1 -1
- package/dist/repository/userrole.repository.js.map +1 -1
- package/dist/repository/workflow.repository.js +0 -1
- package/dist/repository/workflow.repository.js.map +1 -1
- package/dist/routes/accountdetails.route.js +2 -2
- package/dist/routes/accountdetails.route.js.map +1 -1
- package/dist/routes/auth.route.js +6 -5
- package/dist/routes/auth.route.js.map +1 -1
- package/dist/routes/document.route.js +4 -2
- package/dist/routes/document.route.js.map +1 -1
- package/dist/routes/fileSystem.route.js +2 -1
- package/dist/routes/fileSystem.route.js.map +1 -1
- package/dist/routes/form.route.js +2 -2
- package/dist/routes/form.route.js.map +1 -1
- package/dist/routes/index.js +1 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/log.route.js +3 -3
- package/dist/routes/log.route.js.map +1 -1
- package/dist/routes/notifications.route.js +1 -1
- package/dist/routes/notifications.route.js.map +1 -1
- package/dist/routes/org.route.js +2 -2
- package/dist/routes/org.route.js.map +1 -1
- package/dist/routes/profile.route.js +4 -3
- package/dist/routes/profile.route.js.map +1 -1
- package/dist/routes/role.route.js +7 -4
- package/dist/routes/role.route.js.map +1 -1
- package/dist/routes/user.route.js +12 -10
- package/dist/routes/user.route.js.map +1 -1
- package/dist/routes/userrole.route.js +6 -4
- package/dist/routes/userrole.route.js.map +1 -1
- package/dist/routes/workflow.route.js +3 -3
- package/dist/routes/workflow.route.js.map +1 -1
- package/dist/server.js +1 -3
- package/dist/server.js.map +1 -1
- package/dist/services/apikey/apikey.service.js +102 -0
- package/dist/services/apikey/apikey.service.js.map +1 -0
- package/dist/services/authentication/change-password.service.js +4 -4
- package/dist/services/authentication/change-password.service.js.map +1 -1
- package/dist/services/authentication/forgot-password.service.js +6 -6
- package/dist/services/authentication/forgot-password.service.js.map +1 -1
- package/dist/services/authentication/getuser.service.js +2 -2
- package/dist/services/authentication/getuser.service.js.map +1 -1
- package/dist/services/authentication/login.service.js +4 -4
- package/dist/services/authentication/login.service.js.map +1 -1
- package/dist/services/authentication/register.admin.service.js +1 -1
- package/dist/services/authentication/register.admin.service.js.map +1 -1
- package/dist/services/authentication/register.service.js +8 -8
- package/dist/services/authentication/register.service.js.map +1 -1
- package/dist/services/authentication/resend-email.service.js +6 -6
- package/dist/services/authentication/resend-email.service.js.map +1 -1
- package/dist/services/authentication/reset-password.service.js +29 -11
- package/dist/services/authentication/reset-password.service.js.map +1 -1
- package/dist/services/authentication/verify-email.service.js +4 -4
- package/dist/services/authentication/verify-email.service.js.map +1 -1
- package/dist/services/document/document.services.js +177 -94
- package/dist/services/document/document.services.js.map +1 -1
- package/dist/services/document/dummy.js +85 -0
- package/dist/services/document/dummy.js.map +1 -0
- package/dist/services/fileSystem/fileSystem.service.js +1 -1
- package/dist/services/fileSystem/fileSystem.service.js.map +1 -1
- package/dist/services/form/form.service.js +1 -1
- package/dist/services/form/form.service.js.map +1 -1
- package/dist/services/logs/log.service.js +1 -1
- package/dist/services/logs/log.service.js.map +1 -1
- package/dist/services/notifications/notifications.service.js +1 -1
- package/dist/services/notifications/notifications.service.js.map +1 -1
- package/dist/services/organisation/organisation.service.js +2 -2
- package/dist/services/organisation/organisation.service.js.map +1 -1
- package/dist/services/profile/profile.services.js +1 -1
- package/dist/services/profile/profile.services.js.map +1 -1
- package/dist/services/roles/role.services.js +1 -1
- package/dist/services/roles/role.services.js.map +1 -1
- package/dist/services/statement/accountdetails.service.js +1 -1
- package/dist/services/statement/accountdetails.service.js.map +1 -1
- package/dist/services/userroles/userrole.service.js +1 -1
- package/dist/services/userroles/userrole.service.js.map +1 -1
- package/dist/services/workflow/workSettings.service.js +1 -1
- package/dist/services/workflow/workSettings.service.js.map +1 -1
- package/dist/services/workflow/workflow.service.js +9 -7
- package/dist/services/workflow/workflow.service.js.map +1 -1
- package/dist/types/controllers/auth.controller.d.ts +4 -4
- package/dist/types/repository/document.repository.d.ts +56 -16
- package/dist/types/repository/form.repository.d.ts +7 -3
- package/dist/types/repository/organisation.repository.d.ts +1 -6
- package/dist/types/repository/profile.repository.d.ts +4 -3
- package/dist/types/repository/role.repository.d.ts +5 -2
- package/dist/types/repository/schemas/accounts.schema.d.ts +14 -11
- package/dist/types/repository/schemas/document.schema.d.ts +4 -4
- package/dist/types/repository/schemas/extracted.schema.d.ts +3 -3
- package/dist/types/repository/schemas/fileSystem.schema.d.ts +2 -6
- package/dist/types/repository/schemas/form.schema.d.ts +1 -1
- package/dist/types/repository/schemas/organisation.schema.d.ts +11 -11
- package/dist/types/repository/schemas/profile.schema.d.ts +1 -1
- package/dist/types/repository/schemas/role.schema.d.ts +1 -1
- package/dist/types/repository/schemas/userrole.schema.d.ts +1 -1
- package/dist/types/repository/schemas/workflow.schema.d.ts +2 -14
- package/dist/types/repository/user.repository.d.ts +45 -16
- package/dist/types/repository/userrole.repository.d.ts +5 -2
- package/dist/types/repository/workflow.repository.d.ts +4 -38
- package/dist/types/server.d.ts +0 -1
- package/dist/types/services/apikey/apikey.service.d.ts +12 -0
- package/dist/types/services/authentication/change-password.service.d.ts +1 -1
- package/dist/types/services/authentication/forgot-password.service.d.ts +2 -2
- package/dist/types/services/authentication/getuser.service.d.ts +29 -3
- package/dist/types/services/authentication/login.service.d.ts +1 -1
- package/dist/types/services/authentication/register.admin.service.d.ts +1 -1
- package/dist/types/services/authentication/register.service.d.ts +1 -1
- package/dist/types/services/authentication/resend-email.service.d.ts +2 -2
- package/dist/types/services/authentication/reset-password.service.d.ts +2 -2
- package/dist/types/services/authentication/verify-email.service.d.ts +1 -1
- package/dist/types/services/document/document.services.d.ts +42 -12
- package/dist/types/services/document/dummy.d.ts +45 -0
- package/dist/types/services/logs/log.service.d.ts +1 -1
- package/dist/types/services/profile/profile.services.d.ts +3 -3
- package/dist/types/services/roles/role.services.d.ts +33 -5
- package/dist/types/services/userroles/userrole.service.d.ts +5 -13
- package/dist/types/services/workflow/workflow.service.d.ts +2 -2
- package/dist/types/utils/common.d.ts +5 -0
- package/dist/utils/common.js +23 -1
- package/dist/utils/common.js.map +1 -1
- package/package.json +1 -1
- package/src/config/auth/passportConfig.ts +5 -2
- package/src/controllers/auth.controller.ts +3 -3
- package/src/controllers/rbac/rbac.controller.ts +1 -2
- package/src/helpers/jwt.helper.ts +1 -1
- package/src/libs/mail.ts +2 -2
- package/src/repository/accountdetails.repository.ts +1 -1
- package/src/repository/document.repository.ts +222 -38
- package/src/repository/filesystem.repository.ts +5 -5
- package/src/repository/form.repository.ts +4 -4
- package/src/repository/log.repository.ts +3 -3
- package/src/repository/notifications.repository.ts +2 -1
- package/src/repository/organisation.repository.ts +1 -1
- package/src/repository/profile.repository.ts +1 -1
- package/src/repository/role.repository.ts +1 -1
- package/src/repository/schemas/WorkflowSettingsScheme.ts +0 -2
- package/src/repository/schemas/accountdetails.schema.ts +2 -5
- package/src/repository/schemas/accounts.schema.ts +30 -31
- package/src/repository/schemas/document.schema.ts +15 -18
- package/src/repository/schemas/extracted.schema.ts +28 -31
- package/src/repository/schemas/fileSystem.schema.ts +4 -7
- package/src/repository/schemas/form.schema.ts +1 -2
- package/src/repository/schemas/log.schema.ts +6 -7
- package/src/repository/schemas/notifications.schema.ts +2 -4
- package/src/repository/schemas/organisation.schema.ts +44 -51
- package/src/repository/schemas/profile.schema.ts +1 -2
- package/src/repository/schemas/role.schema.ts +1 -2
- package/src/repository/schemas/tokens.schema.ts +18 -20
- package/src/repository/schemas/userrole.schema.ts +1 -2
- package/src/repository/schemas/workflow.schema.ts +41 -61
- package/src/repository/user.repository.ts +75 -54
- package/src/repository/user_tokens.repository.ts +3 -3
- package/src/repository/userrole.repository.ts +2 -2
- package/src/repository/workflow.repository.ts +4 -5
- package/src/routes/accountdetails.route.ts +3 -2
- package/src/routes/auth.route.ts +6 -5
- package/src/routes/document.route.ts +6 -2
- package/src/routes/fileSystem.route.ts +3 -1
- package/src/routes/form.route.ts +7 -2
- package/src/routes/index.ts +2 -1
- package/src/routes/log.route.ts +4 -4
- package/src/routes/notifications.route.ts +1 -1
- package/src/routes/org.route.ts +2 -2
- package/src/routes/profile.route.ts +4 -3
- package/src/routes/role.route.ts +7 -4
- package/src/routes/user.route.ts +30 -8
- package/src/routes/userrole.route.ts +6 -4
- package/src/routes/workflow.route.ts +12 -4
- package/src/server.ts +0 -1
- package/src/services/authentication/change-password.service.ts +8 -8
- package/src/services/authentication/forgot-password.service.ts +8 -8
- package/src/services/authentication/getuser.service.ts +3 -3
- package/src/services/authentication/login.service.ts +5 -5
- package/src/services/authentication/register.admin.service.ts +2 -2
- package/src/services/authentication/register.service.ts +9 -9
- package/src/services/authentication/resend-email.service.ts +10 -10
- package/src/services/authentication/reset-password.service.ts +37 -16
- package/src/services/authentication/verify-email.service.ts +5 -5
- package/src/services/document/document.services.ts +222 -124
- package/src/services/document/dummy.ts +81 -0
- package/src/services/fileSystem/fileSystem.service.ts +8 -4
- package/src/services/form/form.service.ts +1 -1
- package/src/services/logs/log.service.ts +2 -2
- package/src/services/notifications/notifications.service.ts +9 -9
- package/src/services/organisation/organisation.service.ts +8 -8
- package/src/services/profile/profile.services.ts +6 -6
- package/src/services/roles/role.services.ts +5 -5
- package/src/services/statement/accountdetails.service.ts +2 -2
- package/src/services/userroles/userrole.service.ts +6 -6
- package/src/services/workflow/workSettings.service.ts +2 -2
- package/src/services/workflow/workflow.service.ts +18 -12
- package/src/utils/common.ts +36 -13
- package/.vscode/extensions.json +0 -5
- package/dist/controllers/rbac/grantaccess.json +0 -72
- package/dist/setupModal.js +0 -58
- package/dist/setupModal.js.map +0 -1
- package/dist/types/setupModal.d.ts +0 -7
- package/src/setupModal.ts +0 -60
package/src/routes/user.route.ts
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
changePasswordUser,
|
|
5
|
+
registerUser,
|
|
6
|
+
isLoggedIn,
|
|
7
|
+
getalluser,
|
|
8
|
+
getPermissionsService,
|
|
9
|
+
} from "~/services/authentication";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
deleteUser,
|
|
13
|
+
deleteUserHandler,
|
|
14
|
+
getCurrentUser,
|
|
15
|
+
updateUserHandler,
|
|
16
|
+
} from "~/services/authentication/login.service";
|
|
17
|
+
|
|
18
|
+
import { authenticateJWT } from "~/controllers/auth.controller";
|
|
19
|
+
|
|
20
|
+
import { grantAccess } from "~/controllers/rbac/rbac.controller";
|
|
21
|
+
import {
|
|
22
|
+
getUserAccountService,
|
|
23
|
+
updateUserAccountDetailsService,
|
|
24
|
+
} from "~/services/authentication/getuser.service";
|
|
6
25
|
|
|
7
26
|
const User = express.Router();
|
|
8
27
|
|
|
9
|
-
|
|
28
|
+
User.get("/isLoggedIn", authenticateJWT, isLoggedIn);
|
|
10
29
|
|
|
11
|
-
|
|
30
|
+
User.post("/changePassword", authenticateJWT, changePasswordUser);
|
|
12
31
|
|
|
13
32
|
User.delete("/logout", (req, res, next) => {
|
|
14
33
|
req.logOut((err) => {
|
|
@@ -21,18 +40,21 @@ User.delete("/logout", (req, res, next) => {
|
|
|
21
40
|
|
|
22
41
|
User.post("/create", authenticateJWT, registerUser); // authenticateJWT, grantAccess('canCreateUser', 'User'),
|
|
23
42
|
|
|
24
|
-
User.get('/get', authenticateJWT, getalluser)
|
|
43
|
+
// User.get('/get', authenticateJWT, grantAccess('get', 'user'), getalluser)
|
|
25
44
|
|
|
45
|
+
User.get("/get", authenticateJWT, getalluser);
|
|
26
46
|
|
|
27
47
|
User.delete(
|
|
28
48
|
"/delete/:id",
|
|
29
49
|
authenticateJWT,
|
|
50
|
+
grantAccess("delete", "user"),
|
|
30
51
|
deleteUserHandler
|
|
31
52
|
);
|
|
32
53
|
|
|
33
54
|
User.put(
|
|
34
55
|
"/update/:id",
|
|
35
56
|
authenticateJWT,
|
|
57
|
+
grantAccess("update", "user"),
|
|
36
58
|
updateUserHandler
|
|
37
59
|
);
|
|
38
60
|
|
|
@@ -45,6 +67,6 @@ User.put(
|
|
|
45
67
|
authenticateJWT,
|
|
46
68
|
updateUserAccountDetailsService
|
|
47
69
|
);
|
|
48
|
-
User.delete('/delete/:Id', deleteUser);
|
|
70
|
+
//User.delete('/delete/:Id', deleteUser);
|
|
49
71
|
|
|
50
72
|
export default User;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
3
|
+
import { createUserRoleService, deleteRoleService, getRoleById, getUserRolesService } from '~/services/userroles/userrole.service';
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
const UserRole = express.Router();
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
UserRole.post('/create', authenticateJWT, createUserRoleService )
|
|
9
|
+
UserRole.get('/get',authenticateJWT, getUserRolesService )
|
|
10
|
+
UserRole.get('/getbyid/:id',authenticateJWT, getRoleById)
|
|
11
|
+
UserRole.delete('/delete/:id',authenticateJWT, deleteRoleService )
|
|
10
12
|
|
|
11
13
|
export default UserRole;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
-
import { authenticateJWT } from "
|
|
2
|
+
import { authenticateJWT } from "~/controllers/auth.controller";
|
|
3
3
|
import {
|
|
4
4
|
createWorkflowSettingService,
|
|
5
5
|
getWorkflowSettingsService,
|
|
6
|
-
} from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
} from "~/services/workflow/workSettings.service";
|
|
7
|
+
import {
|
|
8
|
+
createWorkFlowService,
|
|
9
|
+
deleteWorkflow,
|
|
10
|
+
getDefaultWorkFlowService,
|
|
11
|
+
getallUsersWorkFlowService,
|
|
12
|
+
getallWorkFlowService,
|
|
13
|
+
updateWorkFlowService,
|
|
14
|
+
updateWorkFlowStatusService,
|
|
15
|
+
updateWorkFlowUserStatus,
|
|
16
|
+
} from "~/services/workflow/workflow.service";
|
|
9
17
|
|
|
10
18
|
const WorkFlow = express.Router();
|
|
11
19
|
|
package/src/server.ts
CHANGED
|
@@ -13,4 +13,3 @@ export { default as UserRole } from './routes/userrole.route';
|
|
|
13
13
|
export { default as Document } from './routes/document.route';
|
|
14
14
|
export { default as WorkFlow } from './routes/workflow.route';
|
|
15
15
|
export { default as Form } from './routes/form.route';
|
|
16
|
-
export {setupLibrary as setupLibrary} from './setupModal'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from "express";
|
|
2
2
|
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
|
-
import { findUser } from "
|
|
5
|
-
import logger from "
|
|
6
|
-
import sendMail from "
|
|
7
|
-
import compileEmailTemplate from "
|
|
4
|
+
import { findUser } from "~/repository/user.repository";
|
|
5
|
+
import logger from "~/utils/logger";
|
|
6
|
+
import sendMail from "~/libs/mail";
|
|
7
|
+
import compileEmailTemplate from "~/helpers/compile-email-template";
|
|
8
8
|
|
|
9
|
-
import { changePasswordValidation } from "
|
|
9
|
+
import { changePasswordValidation } from "~/validations/authenticate.validation";
|
|
10
10
|
import { createNotificationsService } from "../notifications/notifications.service";
|
|
11
11
|
import { getUserServiceByLevel } from "./getuser.service";
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ export async function changePasswordUser(
|
|
|
25
25
|
req: UserRequest,
|
|
26
26
|
res: Response,
|
|
27
27
|
next: NextFunction
|
|
28
|
-
): Promise<
|
|
28
|
+
): Promise<any> {
|
|
29
29
|
try {
|
|
30
30
|
const { currentPassword, newPassword, confirmPassword, id } = req.body;
|
|
31
31
|
if (!req.user) {
|
|
@@ -49,7 +49,7 @@ export async function changePasswordUser(
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
let user;
|
|
52
|
+
let user :any = null;
|
|
53
53
|
if (!id) {
|
|
54
54
|
user = req.user;
|
|
55
55
|
const updatePassword = await user.changePassword(
|
|
@@ -97,7 +97,7 @@ export async function changePasswordUser(
|
|
|
97
97
|
|
|
98
98
|
export async function changeWorkFlowUserPassword(id: string, password: string) {
|
|
99
99
|
try {
|
|
100
|
-
let user = await findUser({ id });
|
|
100
|
+
let user : any = await findUser({ id });
|
|
101
101
|
if (user) {
|
|
102
102
|
user.setPassword(password, async (err: any, user: any) => {
|
|
103
103
|
if (err) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
|
|
3
3
|
import { findUser, getUserByIdAndJoinUserToken } from '../../repository/user.repository';
|
|
4
|
-
import generateRandomKey from '
|
|
5
|
-
import { createToken, updateUserTokenById } from '
|
|
6
|
-
import logger from '
|
|
7
|
-
import sendMail from '
|
|
8
|
-
import compileEmailTemplate from '
|
|
9
|
-
import { SEND_MAIL_TYPE } from '
|
|
4
|
+
import generateRandomKey from '~/helpers/genarateRandomkey';
|
|
5
|
+
import { createToken, updateUserTokenById } from '~/repository/user_tokens.repository';
|
|
6
|
+
import logger from '~/utils/logger';
|
|
7
|
+
import sendMail from '~/libs/mail';
|
|
8
|
+
import compileEmailTemplate from '~/helpers/compile-email-template';
|
|
9
|
+
import { SEND_MAIL_TYPE } from '~/constants/send-mail-type.constant';
|
|
10
10
|
|
|
11
|
-
export async function forgotPasswordUser(req:
|
|
11
|
+
export async function forgotPasswordUser(req: Request, res: Response, next: NextFunction): Promise<any> {
|
|
12
12
|
try {
|
|
13
13
|
const { email } = req.body;
|
|
14
|
-
const user
|
|
14
|
+
const user = await findUser({ email });
|
|
15
15
|
if (!user || !user._id) {
|
|
16
16
|
return res.status(300).json({ status:'error', message: "User doesn't exist" })
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from "express";
|
|
2
|
-
import { updateorganisation } from "
|
|
3
|
-
import accountsSchema from "
|
|
2
|
+
import { updateorganisation } from "~/repository/organisation.repository";
|
|
3
|
+
import accountsSchema from "~/repository/schemas/accounts.schema";
|
|
4
4
|
import {
|
|
5
5
|
getallusers,
|
|
6
6
|
getCompanyByUserId,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getUserByLevel,
|
|
10
10
|
updateUserAccountDetails,
|
|
11
11
|
updateUserWorkFlowStatus,
|
|
12
|
-
} from "
|
|
12
|
+
} from "~/repository/user.repository";
|
|
13
13
|
import { createNotificationsService } from "../notifications/notifications.service";
|
|
14
14
|
import { findOrgDetailsService } from "../organisation/organisation.service";
|
|
15
15
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { deleteUserById, findUser, findUserProps, getUser, updateUser } from '
|
|
3
|
-
import { loginValidation } from '
|
|
2
|
+
import { deleteUserById, findUser, findUserProps, getUser, updateUser } from '~/repository/user.repository';
|
|
3
|
+
import { loginValidation } from '~/validations/authenticate.validation';
|
|
4
4
|
import passport from 'passport';
|
|
5
5
|
import * as jwt from 'jsonwebtoken'
|
|
6
|
-
import { JWT_SECRET } from "
|
|
7
|
-
import { clearCookie, COOKIE_NAME } from '
|
|
6
|
+
import { JWT_SECRET } from "~/utils/env";
|
|
7
|
+
import { clearCookie, COOKIE_NAME } from '~/utils/cookie';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
interface UserRequest extends Request {
|
|
@@ -52,7 +52,7 @@ export async function loginUser(req: Request, res: Response, next: NextFunction)
|
|
|
52
52
|
})(req, res, next);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export async function isLoggedIn(req:
|
|
55
|
+
export async function isLoggedIn(req: Request, res: Response, next: NextFunction): Promise<any> {
|
|
56
56
|
if (req.user) {
|
|
57
57
|
return res.status(200).send(true)
|
|
58
58
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
|
|
3
|
-
import { findOrg, createOrg } from '
|
|
3
|
+
import { findOrg, createOrg } from '~/repository/organisation.repository';
|
|
4
4
|
|
|
5
5
|
import { registerUser } from './register.service';
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ interface UserRequest extends Request {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export async function registerAdmin(req: UserRequest, res: Response, next: NextFunction): Promise<
|
|
13
|
+
export async function registerAdmin(req: UserRequest, res: Response, next: NextFunction): Promise<any> {
|
|
14
14
|
try {
|
|
15
15
|
let { email, company, gstNumber, license, type } = req.body;
|
|
16
16
|
if (!type) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
import mongoose from 'mongoose';
|
|
3
|
-
import { findUser, createUser, createWorkFlowUser } from '
|
|
4
|
-
import { createToken } from '
|
|
5
|
-
import { registerValidation } from '
|
|
6
|
-
import sendMail from '
|
|
7
|
-
import { SEND_MAIL_TYPE } from '
|
|
8
|
-
import compileEmailTemplate from '
|
|
9
|
-
import generateRandomKey from '
|
|
10
|
-
import { sign } from '
|
|
11
|
-
import { updateUserHandler } from '
|
|
3
|
+
import { findUser, createUser, createWorkFlowUser } from '~/repository/user.repository';
|
|
4
|
+
import { createToken } from '~/repository/user_tokens.repository';
|
|
5
|
+
import { registerValidation } from '~/validations/authenticate.validation';
|
|
6
|
+
import sendMail from '~/libs/mail';
|
|
7
|
+
import { SEND_MAIL_TYPE } from '~/constants/send-mail-type.constant';
|
|
8
|
+
import compileEmailTemplate from '~/helpers/compile-email-template';
|
|
9
|
+
import generateRandomKey from '~/helpers/genarateRandomkey';
|
|
10
|
+
import { sign } from '~/helpers/jwt.helper';
|
|
11
|
+
import { updateUserHandler } from '~/services/authentication/login.service';
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
interface UserRequest extends Request {
|
|
@@ -3,23 +3,23 @@ import { NextFunction, Request, Response } from 'express';
|
|
|
3
3
|
import {
|
|
4
4
|
changeTokenStatus,
|
|
5
5
|
createToken,
|
|
6
|
-
} from '
|
|
6
|
+
} from '~/repository/user_tokens.repository';
|
|
7
7
|
|
|
8
|
-
import { normalizeEmail } from '
|
|
8
|
+
import { normalizeEmail } from '~/helpers/string.helper';
|
|
9
9
|
|
|
10
|
-
import type { UserProfile } from '
|
|
10
|
+
import type { UserProfile } from '~/repository/user.repository';
|
|
11
11
|
|
|
12
|
-
import generateRandomKey from '
|
|
13
|
-
import compileEmailTemplate from '
|
|
14
|
-
import sendMail from '
|
|
15
|
-
import { SEND_MAIL_TYPE } from '
|
|
12
|
+
import generateRandomKey from '~/helpers/genarateRandomkey';
|
|
13
|
+
import compileEmailTemplate from '~/helpers/compile-email-template';
|
|
14
|
+
import sendMail from '~/libs/mail';
|
|
15
|
+
import { SEND_MAIL_TYPE } from '~/constants/send-mail-type.constant';
|
|
16
16
|
|
|
17
|
-
import type { VerifyTokenRequest } from '
|
|
17
|
+
import type { VerifyTokenRequest } from '~/services/authentication/verify-email.service';
|
|
18
18
|
|
|
19
|
-
export async function resendEmailAction(req:
|
|
19
|
+
export async function resendEmailAction(req: Request, res: Response, next: NextFunction): Promise<any> {
|
|
20
20
|
try {
|
|
21
21
|
const type = req.body.type;
|
|
22
|
-
const user = req.user as
|
|
22
|
+
const user = req.user as UserProfile;
|
|
23
23
|
|
|
24
24
|
let template;
|
|
25
25
|
let subject;
|
|
@@ -1,52 +1,73 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import { NextFunction, Request, Response } from 'express';
|
|
3
3
|
|
|
4
|
-
import { findUser } from '
|
|
5
|
-
import { findToken, removeUserToken } from '
|
|
6
|
-
import logger from '
|
|
7
|
-
import { changePasswordValidation } from '
|
|
4
|
+
import { findUser } from '~/repository/user.repository';
|
|
5
|
+
import { findToken, removeUserToken } from '~/repository/user_tokens.repository';
|
|
6
|
+
import logger from '~/utils/logger';
|
|
7
|
+
import { changePasswordValidation } from '~/validations/authenticate.validation';
|
|
8
8
|
import { resendEmailAction } from './resend-email.service';
|
|
9
9
|
|
|
10
|
-
export async function resetPasswordUser(
|
|
10
|
+
export async function resetPasswordUser(
|
|
11
|
+
req: Request,
|
|
12
|
+
res: Response,
|
|
13
|
+
next: NextFunction
|
|
14
|
+
): Promise<any> {
|
|
11
15
|
try {
|
|
12
16
|
const { token, password, confirmPassword } = req.body;
|
|
13
17
|
|
|
18
|
+
console.log(token)
|
|
14
19
|
const validateResult = changePasswordValidation({ password });
|
|
15
20
|
if (Array.isArray(validateResult) && validateResult.length) {
|
|
16
|
-
return res
|
|
21
|
+
return res
|
|
22
|
+
.status(300)
|
|
23
|
+
.json({ message: validateResult.map((it) => it.message).join(",") });
|
|
17
24
|
}
|
|
18
25
|
if (password !== confirmPassword) {
|
|
19
|
-
return res
|
|
26
|
+
return res
|
|
27
|
+
.status(300)
|
|
28
|
+
.json({
|
|
29
|
+
status: "error",
|
|
30
|
+
message: "Password and Confirm password do not match",
|
|
31
|
+
});
|
|
20
32
|
}
|
|
21
33
|
const session = await findToken(token);
|
|
22
|
-
|
|
34
|
+
console.log(session)
|
|
35
|
+
const user : any = await findUser({ id: session.user_id });
|
|
23
36
|
|
|
24
37
|
if (!user) {
|
|
25
|
-
return res
|
|
38
|
+
return res
|
|
39
|
+
.status(300)
|
|
40
|
+
.json({ status: "error", message: "User not found" });
|
|
26
41
|
}
|
|
27
42
|
|
|
28
|
-
req.user = user
|
|
29
|
-
req.body.type = token.type
|
|
43
|
+
req.user = user;
|
|
44
|
+
req.body.type = token.type;
|
|
30
45
|
|
|
31
46
|
if (!session || !session._id) {
|
|
32
47
|
return resendEmailAction(req, res, next);
|
|
33
48
|
}
|
|
34
49
|
|
|
35
|
-
if (dayjs(session.updated_at).add(15,
|
|
50
|
+
if (dayjs(session.updated_at).add(15, "m").diff(dayjs()) < 0) {
|
|
36
51
|
return resendEmailAction(req, res, next);
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
await user.setPassword(password, (err: any, user: any) => {
|
|
40
55
|
if (err) {
|
|
41
|
-
return res
|
|
56
|
+
return res
|
|
57
|
+
.status(300)
|
|
58
|
+
.json({
|
|
59
|
+
status: "error",
|
|
60
|
+
message: "Your password has not been updated",
|
|
61
|
+
});
|
|
42
62
|
}
|
|
43
63
|
user.save();
|
|
44
64
|
removeUserToken(session._id);
|
|
45
|
-
return res
|
|
65
|
+
return res
|
|
66
|
+
.status(200)
|
|
67
|
+
.json({ status: "success", message: "Your password has been updated" });
|
|
46
68
|
});
|
|
47
|
-
|
|
48
69
|
} catch (error) {
|
|
49
70
|
logger.error(error);
|
|
50
|
-
return res.status(400).json({ status:
|
|
71
|
+
return res.status(400).json({ status: "error", message: error });
|
|
51
72
|
}
|
|
52
73
|
}
|
|
@@ -3,11 +3,11 @@ import dayjs from 'dayjs';
|
|
|
3
3
|
import {
|
|
4
4
|
findToken,
|
|
5
5
|
changeTokenStatus
|
|
6
|
-
} from '
|
|
7
|
-
import { activeUser, findUser } from '
|
|
6
|
+
} from '~/repository/user_tokens.repository';
|
|
7
|
+
import { activeUser, findUser } from '~/repository/user.repository';
|
|
8
8
|
|
|
9
|
-
import logger from '
|
|
10
|
-
import { SEND_MAIL_TYPE } from '
|
|
9
|
+
import logger from '~/utils/logger';
|
|
10
|
+
import { SEND_MAIL_TYPE } from '~/constants/send-mail-type.constant';
|
|
11
11
|
|
|
12
12
|
import { resendEmailAction } from './resend-email.service';
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ export type VerifyTokenRequest = Request & {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export async function verifyEmail(req:
|
|
24
|
+
export async function verifyEmail(req: VerifyTokenRequest, res: Response, next: NextFunction): Promise<any> {
|
|
25
25
|
try {
|
|
26
26
|
const authToken: string = req.query.token;
|
|
27
27
|
console.log(authToken);
|