@tomei/sso 0.64.0-staging.2 → 0.64.1

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.
Files changed (126) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.gitlab-ci.yml +16 -16
  3. package/.husky/commit-msg +15 -9
  4. package/.husky/pre-commit +7 -7
  5. package/.prettierrc +4 -4
  6. package/Jenkinsfile +57 -57
  7. package/README.md +23 -23
  8. package/__tests__/unit/components/group/group.spec.ts +79 -79
  9. package/__tests__/unit/components/group-object-privilege/group-object-privilege.spec.ts +88 -88
  10. package/__tests__/unit/components/group-privilege/group-privilege.spec.ts +68 -68
  11. package/__tests__/unit/components/group-reporting-user/group-reporting-user.spec.ts +66 -66
  12. package/__tests__/unit/components/group-system-access/group-system-access.spec.ts +83 -83
  13. package/__tests__/unit/components/login-user/l.spec.ts +746 -746
  14. package/__tests__/unit/components/login-user/login.spec.ts +1164 -1164
  15. package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
  16. package/__tests__/unit/components/system/system.spec.ts +254 -254
  17. package/__tests__/unit/components/system-privilege/system-privilege.spec.ts +83 -83
  18. package/__tests__/unit/components/user-group/user-group.spec.ts +86 -86
  19. package/__tests__/unit/components/user-object-privilege/user-object-privilege.spec.ts +78 -78
  20. package/__tests__/unit/components/user-privilege/user-privilege.spec.ts +72 -72
  21. package/__tests__/unit/components/user-system-access/user-system-access.spec.ts +89 -89
  22. package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
  23. package/__tests__/unit/session/session.service.spec.ts +47 -47
  24. package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
  25. package/coverage/clover.xml +1380 -0
  26. package/coverage/coverage-final.json +39 -0
  27. package/coverage/lcov-report/base.css +224 -0
  28. package/coverage/lcov-report/block-navigation.js +87 -0
  29. package/coverage/lcov-report/components/group-object-privilege/group-object-privilege.repository.ts.html +160 -0
  30. package/coverage/lcov-report/components/group-object-privilege/group-object-privilege.ts.html +919 -0
  31. package/coverage/lcov-report/components/group-object-privilege/index.html +131 -0
  32. package/coverage/lcov-report/components/group-privilege/group-privilege.repository.ts.html +172 -0
  33. package/coverage/lcov-report/components/group-privilege/group-privilege.ts.html +337 -0
  34. package/coverage/lcov-report/components/group-privilege/index.html +131 -0
  35. package/coverage/lcov-report/components/group-system-access/group-system-access.repository.ts.html +214 -0
  36. package/coverage/lcov-report/components/group-system-access/group-system-access.ts.html +355 -0
  37. package/coverage/lcov-report/components/group-system-access/index.html +131 -0
  38. package/coverage/lcov-report/components/password-hash/index.html +116 -0
  39. package/coverage/lcov-report/components/password-hash/password-hash.service.ts.html +127 -0
  40. package/coverage/lcov-report/components/system-privilege/index.html +116 -0
  41. package/coverage/lcov-report/components/system-privilege/system-privilege.repository.ts.html +139 -0
  42. package/coverage/lcov-report/components/user-group/index.html +131 -0
  43. package/coverage/lcov-report/components/user-group/user-group.repository.ts.html +142 -0
  44. package/coverage/lcov-report/components/user-group/user-group.ts.html +2377 -0
  45. package/coverage/lcov-report/components/user-object-privilege/index.html +131 -0
  46. package/coverage/lcov-report/components/user-object-privilege/user-object-privilege.repository.ts.html +118 -0
  47. package/coverage/lcov-report/components/user-object-privilege/user-object-privilege.ts.html +322 -0
  48. package/coverage/lcov-report/components/user-privilege/index.html +131 -0
  49. package/coverage/lcov-report/components/user-privilege/user-privilege.repository.ts.html +160 -0
  50. package/coverage/lcov-report/components/user-privilege/user-privilege.ts.html +2071 -0
  51. package/coverage/lcov-report/components/user-system-access/index.html +131 -0
  52. package/coverage/lcov-report/components/user-system-access/user-system-access.repository.ts.html +208 -0
  53. package/coverage/lcov-report/components/user-system-access/user-system-access.ts.html +2236 -0
  54. package/coverage/lcov-report/enum/api-key.enum.ts.html +100 -0
  55. package/coverage/lcov-report/enum/group-type.enum.ts.html +109 -0
  56. package/coverage/lcov-report/enum/index.html +206 -0
  57. package/coverage/lcov-report/enum/index.ts.html +103 -0
  58. package/coverage/lcov-report/enum/login-status.enum.ts.html +97 -0
  59. package/coverage/lcov-report/enum/object-status.enum.ts.html +97 -0
  60. package/coverage/lcov-report/enum/user-status.enum.ts.html +106 -0
  61. package/coverage/lcov-report/enum/yn.enum.ts.html +97 -0
  62. package/coverage/lcov-report/favicon.png +0 -0
  63. package/coverage/lcov-report/index.html +296 -0
  64. package/coverage/lcov-report/models/group-object-privilege.entity.ts.html +358 -0
  65. package/coverage/lcov-report/models/group-privilege.entity.ts.html +319 -0
  66. package/coverage/lcov-report/models/group-reporting-user.entity.ts.html +370 -0
  67. package/coverage/lcov-report/models/group-system-access.entity.ts.html +328 -0
  68. package/coverage/lcov-report/models/group.entity.ts.html +466 -0
  69. package/coverage/lcov-report/models/index.html +296 -0
  70. package/coverage/lcov-report/models/staff.entity.ts.html +358 -0
  71. package/coverage/lcov-report/models/system-privilege.entity.ts.html +355 -0
  72. package/coverage/lcov-report/models/system.entity.ts.html +424 -0
  73. package/coverage/lcov-report/models/user-group.entity.ts.html +358 -0
  74. package/coverage/lcov-report/models/user-object-privilege.entity.ts.html +355 -0
  75. package/coverage/lcov-report/models/user-privilege.entity.ts.html +319 -0
  76. package/coverage/lcov-report/models/user-system-access.entity.ts.html +346 -0
  77. package/coverage/lcov-report/models/user.entity.ts.html +685 -0
  78. package/coverage/lcov-report/prettify.css +1 -0
  79. package/coverage/lcov-report/prettify.js +2 -0
  80. package/coverage/lcov-report/redis-client/index.html +116 -0
  81. package/coverage/lcov-report/redis-client/redis.service.ts.html +310 -0
  82. package/coverage/lcov-report/session/index.html +116 -0
  83. package/coverage/lcov-report/session/session.service.ts.html +373 -0
  84. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  85. package/coverage/lcov-report/sorter.js +210 -0
  86. package/coverage/lcov.info +2223 -0
  87. package/coverage/test-report.xml +71 -0
  88. package/create-sso-user.sql +39 -39
  89. package/dist/__tests__/unit/components/group-privilege/group-privilege.test.d.ts +1 -0
  90. package/dist/__tests__/unit/components/group-privilege/group-privilege.test.js +71 -0
  91. package/dist/__tests__/unit/components/group-privilege/group-privilege.test.js.map +1 -0
  92. package/dist/__tests__/unit/components/login-user/login-user.spec.d.ts +0 -0
  93. package/dist/__tests__/unit/components/login-user/login-user.spec.js +6 -0
  94. package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -0
  95. package/dist/src/components/login-user/user.js +9 -3
  96. package/dist/src/components/login-user/user.js.map +1 -1
  97. package/dist/tsconfig.tsbuildinfo +1 -1
  98. package/eslint.config.mjs +58 -58
  99. package/jest.config.js +14 -14
  100. package/migrations/20240314080602-create-user-table.js +124 -124
  101. package/migrations/20240314080603-create-user-group-table.js +85 -85
  102. package/migrations/20240314080604-create-user-user-group-table.js +55 -55
  103. package/migrations/20240314080605-create-login-history-table.js +53 -53
  104. package/migrations/20240527064925-create-system-table.js +78 -78
  105. package/migrations/20240527064926-create-system-privilege-table.js +71 -71
  106. package/migrations/20240527065342-create-group-table.js +93 -93
  107. package/migrations/20240527065633-create-group-reporting-user-table.js +76 -76
  108. package/migrations/20240528011551-create-group-system-access-table.js +72 -72
  109. package/migrations/20240528023018-user-system-access-table.js +75 -75
  110. package/migrations/20240528032229-user-privilege-table.js +76 -76
  111. package/migrations/20240528063003-create-group-privilege-table.js +76 -76
  112. package/migrations/20240528063051-create-group-object-privilege-table.js +84 -84
  113. package/migrations/20240528063107-create-user-object-privilege-table.js +84 -84
  114. package/migrations/20240528063108-create-api-key-table.js +85 -85
  115. package/migrations/20241104104802-create-building-table.js +95 -95
  116. package/migrations/20250108091132-add-area-manager-user-id-to-building-table.js +14 -14
  117. package/migrations/20250108091133-add-passcode-to-user-table.js +36 -36
  118. package/migrations/20250210115636-create-user-reporting-hierarchy.js +76 -76
  119. package/migrations/20250326043818-crate-user-password-history.js +42 -42
  120. package/migrations/20250610070720-added-MFBypassYN-to-sso-user.js +30 -30
  121. package/package.json +87 -87
  122. package/sampledotenv +7 -7
  123. package/sonar-project.properties +23 -0
  124. package/src/components/login-user/user.ts +9 -3
  125. package/tsconfig.build.json +5 -5
  126. package/tsconfig.json +23 -23
@@ -0,0 +1,71 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testExecutions version="1">
3
+ <file path="C:\Work\sso\__tests__\unit\redis-client\redis.service.spec.ts">
4
+ <testCase name="redis.service should return redis service when instansiated" duration="5"/>
5
+ <testCase name="redis.service should able to write and read redis" duration="2"/>
6
+ </file>
7
+ <file path="C:\Work\sso\__tests__\unit\components\user-system-access\user-system-access.spec.ts">
8
+ <testCase name="UserSystemAccess constructor should create a new UserSystemAccess instance" duration="3"/>
9
+ <testCase name="UserSystemAccess init should initialize UserSystemAccess with valid UserSystemAccessId" duration="4"/>
10
+ <testCase name="UserSystemAccess init should throw ClassError when UserSystemAccessId is not found" duration="1"/>
11
+ </file>
12
+ <file path="C:\Work\sso\__tests__\unit\components\user-privilege\user-privilege.spec.ts">
13
+ <testCase name="UserPrivilege constructor should create a new UserPrivilege instance" duration="3"/>
14
+ <testCase name="UserPrivilege init should initialize UserPrivilege with valid UserPrivilegeId" duration="4"/>
15
+ <testCase name="UserPrivilege init should throw ClassError when UserPrivilegeId is not found" duration="10"/>
16
+ </file>
17
+ <file path="C:\Work\sso\__tests__\unit\components\group-object-privilege\group-object-privilege.spec.ts">
18
+ <testCase name="GroupObjectPrivilege should create an instance of GroupObjectPrivilege" duration="2"/>
19
+ <testCase name="GroupObjectPrivilege should have the correct TableName" duration="1"/>
20
+ <testCase name="GroupObjectPrivilege should have the correct properties" duration="1"/>
21
+ <testCase name="GroupObjectPrivilege init should return an instance of GroupObjectPrivilege when GroupObjectPrivilegeId is provided" duration="2"/>
22
+ <testCase name="GroupObjectPrivilege init should throw an error when GroupObjectPrivilegeId is provided but no GroupObjectPrivilege is found" duration="7"/>
23
+ <testCase name="GroupObjectPrivilege init should return a new instance of GroupObjectPrivilege when GroupObjectPrivilegeId is not provided" duration="1"/>
24
+ </file>
25
+ <file path="C:\Work\sso\__tests__\unit\components\user-group\user-group.spec.ts">
26
+ <testCase name="UserGroup constructor should create a new UserGroup instance" duration="3"/>
27
+ <testCase name="UserGroup init should initialize UserGroup with valid UserGroupId" duration="3"/>
28
+ <testCase name="UserGroup init should throw ClassError when UserGroupId is not found" duration="13"/>
29
+ </file>
30
+ <file path="C:\Work\sso\__tests__\unit\components\group-system-access\group-system-access.spec.ts">
31
+ <testCase name="GroupSystemAccess should create a new GroupSystemAccess instance" duration="3"/>
32
+ <testCase name="GroupSystemAccess init should initialize GroupSystemAccess without GroupSystemAccessId" duration="2"/>
33
+ <testCase name="GroupSystemAccess init should initialize GroupSystemAccess with GroupSystemAccessId" duration="2"/>
34
+ <testCase name="GroupSystemAccess init should throw an error if GroupSystemAccessId is not found" duration="4"/>
35
+ </file>
36
+ <file path="C:\Work\sso\__tests__\unit\components\user-object-privilege\user-object-privilege.spec.ts">
37
+ <testCase name="UserObjectPrivilege constructor should create a new UserObjectPrivilege instance" duration="2"/>
38
+ <testCase name="UserObjectPrivilege init should initialize UserObjectPrivilege with valid ObjectPrivilegeId" duration="2"/>
39
+ <testCase name="UserObjectPrivilege init should throw ClassError when ObjectPrivilegeId is not found" duration="4"/>
40
+ </file>
41
+ <file path="C:\Work\sso\__tests__\unit\components\group-privilege\group-privilege.spec.ts">
42
+ <testCase name="GroupPrivilege should initialize with GroupPrivilegeAttr" duration="3"/>
43
+ <testCase name="GroupPrivilege should throw ClassError when GroupPrivilegeAttr is not found" duration="4"/>
44
+ <testCase name="GroupPrivilege should initialize with default values" duration="1"/>
45
+ </file>
46
+ <file path="C:\Work\sso\__tests__\unit\session\session.service.spec.ts">
47
+ <testCase name="session.service should return session service when instansiated" duration="2"/>
48
+ <testCase name="session.service should able to write session data" duration="4"/>
49
+ <testCase name="session.service should able to refresh session data" duration="2"/>
50
+ </file>
51
+ <file path="C:\Work\sso\__tests__\unit\components\password-hash\password-hash.service.spec.ts">
52
+ <testCase name="password-hash.service should return hash password" duration="2"/>
53
+ <testCase name="password-hash.service should return true when verify password" duration="1"/>
54
+ </file>
55
+ <file path="C:\Work\sso\__tests__\unit\components\login-user\l.spec.ts">
56
+ <testCase name="SystemPrivilege should be true" duration="1"/>
57
+ </file>
58
+ <file path="C:\Work\sso\__tests__\unit\system-privilege\system-privilage.spec.ts">
59
+ <testCase name="SystemPrivilege should be true" duration="2"/>
60
+ </file>
61
+ <file path="C:\Work\sso\__tests__\unit\components\system-privilege\system-privilege.spec.ts">
62
+ </file>
63
+ <file path="C:\Work\sso\__tests__\unit\components\system\system.spec.ts">
64
+ </file>
65
+ <file path="C:\Work\sso\__tests__\unit\components\login-user\login.spec.ts">
66
+ </file>
67
+ <file path="C:\Work\sso\__tests__\unit\components\group-reporting-user\group-reporting-user.spec.ts">
68
+ </file>
69
+ <file path="C:\Work\sso\__tests__\unit\components\group\group.spec.ts">
70
+ </file>
71
+ </testExecutions>
@@ -1,40 +1,40 @@
1
-
2
- -- example to create sso-user
3
- CREATE USER 'sso_user'@'environment' IDENTIFIED BY 'password';
4
-
5
- -- example to grant neccesary access to run migration
6
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_authorization_codes TO 'sso_user'@'localhost' WITH GRANT OPTION;
7
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_bearer_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
8
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_building_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
9
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_buildings TO 'sso_user'@'localhost' WITH GRANT OPTION;
10
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_cities TO 'sso_user'@'localhost' WITH GRANT OPTION;
11
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_companies TO 'sso_user'@'localhost' WITH GRANT OPTION;
12
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_countries TO 'sso_user'@'localhost' WITH GRANT OPTION;
13
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_departments TO 'sso_user'@'localhost' WITH GRANT OPTION;
14
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_grouproleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
15
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemaccess TO 'sso_user'@'localhost' WITH GRANT OPTION;
16
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
17
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
18
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_oauth_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
19
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
20
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_sequelize_meta TO 'sso_user'@'localhost' WITH GRANT OPTION;
21
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staff_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
22
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staffs TO 'sso_user'@'localhost' WITH GRANT OPTION;
23
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_states TO 'sso_user'@'localhost' WITH GRANT OPTION;
24
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_system_accesses TO 'sso_user'@'localhost' WITH GRANT OPTION;
25
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
26
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
27
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemroleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
28
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systems TO 'sso_user'@'localhost' WITH GRANT OPTION;
29
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_updated_history TO 'sso_user'@'localhost' WITH GRANT OPTION;
30
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_user_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
31
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usergroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
32
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_users TO 'sso_user'@'localhost' WITH GRANT OPTION;
33
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
34
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
35
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_UserUserGroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
36
- GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production._prisma_migrations TO 'sso_user'@'localhost' WITH GRANT OPTION;
37
-
38
-
39
- -- Grant user to create, alter, drop, references on the database (required for creating shadow tables)
1
+
2
+ -- example to create sso-user
3
+ CREATE USER 'sso_user'@'environment' IDENTIFIED BY 'password';
4
+
5
+ -- example to grant neccesary access to run migration
6
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_authorization_codes TO 'sso_user'@'localhost' WITH GRANT OPTION;
7
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_bearer_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
8
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_building_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
9
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_buildings TO 'sso_user'@'localhost' WITH GRANT OPTION;
10
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_cities TO 'sso_user'@'localhost' WITH GRANT OPTION;
11
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_companies TO 'sso_user'@'localhost' WITH GRANT OPTION;
12
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_countries TO 'sso_user'@'localhost' WITH GRANT OPTION;
13
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_departments TO 'sso_user'@'localhost' WITH GRANT OPTION;
14
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_grouproleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
15
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemaccess TO 'sso_user'@'localhost' WITH GRANT OPTION;
16
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
17
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_groupsystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
18
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_oauth_tokens TO 'sso_user'@'localhost' WITH GRANT OPTION;
19
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
20
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_sequelize_meta TO 'sso_user'@'localhost' WITH GRANT OPTION;
21
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staff_types TO 'sso_user'@'localhost' WITH GRANT OPTION;
22
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_staffs TO 'sso_user'@'localhost' WITH GRANT OPTION;
23
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_states TO 'sso_user'@'localhost' WITH GRANT OPTION;
24
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_system_accesses TO 'sso_user'@'localhost' WITH GRANT OPTION;
25
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
26
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
27
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systemroleprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
28
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_systems TO 'sso_user'@'localhost' WITH GRANT OPTION;
29
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_updated_history TO 'sso_user'@'localhost' WITH GRANT OPTION;
30
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_user_roles TO 'sso_user'@'localhost' WITH GRANT OPTION;
31
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usergroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
32
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_users TO 'sso_user'@'localhost' WITH GRANT OPTION;
33
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemprivilege TO 'sso_user'@'localhost' WITH GRANT OPTION;
34
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_usersystemrole TO 'sso_user'@'localhost' WITH GRANT OPTION;
35
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production.sso_UserUserGroup TO 'sso_user'@'localhost' WITH GRANT OPTION;
36
+ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES on production._prisma_migrations TO 'sso_user'@'localhost' WITH GRANT OPTION;
37
+
38
+
39
+ -- Grant user to create, alter, drop, references on the database (required for creating shadow tables)
40
40
  GRANT CREATE, ALTER, DROP, REFERENCES ON shadow_database.* TO 'sso_user'@'localhost' WITH GRANT OPTION;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const group_privilege_1 = require("../../../../src/components/group-privilege/group-privilege");
13
+ const group_privilege_repository_1 = require("../../../../src/components/group-privilege/group-privilege.repository");
14
+ const general_1 = require("@tomei/general");
15
+ describe('GroupPrivilege', () => {
16
+ afterEach(() => {
17
+ jest.restoreAllMocks();
18
+ });
19
+ it('should initialize with GroupPrivilegeAttr', () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const mockGroupPrivilegeAttr = {
21
+ GroupPrivilegeId: 1,
22
+ GroupCode: 'group1',
23
+ PrivilegeCode: 'privilege1',
24
+ Status: 'active',
25
+ CreatedAt: new Date(),
26
+ UpdatedAt: new Date(),
27
+ CreatedById: 1,
28
+ UpdatedById: 1,
29
+ };
30
+ const findOneMock = jest
31
+ .spyOn(group_privilege_repository_1.GroupPrivilegeRepository.prototype, 'findOne')
32
+ .mockResolvedValueOnce({ get: jest.fn().mockReturnValue(mockGroupPrivilegeAttr) });
33
+ const groupPrivilege = yield group_privilege_1.GroupPrivilege.init(null, 1);
34
+ expect(findOneMock).toBeCalledWith({
35
+ where: { GroupPrivilegeId: 1 },
36
+ transaction: null,
37
+ });
38
+ expect(groupPrivilege).toBeInstanceOf(group_privilege_1.GroupPrivilege);
39
+ expect(groupPrivilege.GroupPrivilegeId).toEqual(mockGroupPrivilegeAttr.GroupPrivilegeId);
40
+ expect(groupPrivilege.GroupCode).toEqual(mockGroupPrivilegeAttr.GroupCode);
41
+ expect(groupPrivilege.PrivilegeCode).toEqual(mockGroupPrivilegeAttr.PrivilegeCode);
42
+ expect(groupPrivilege.Status).toEqual(mockGroupPrivilegeAttr.Status);
43
+ expect(groupPrivilege.CreatedAt).toEqual(mockGroupPrivilegeAttr.CreatedAt);
44
+ expect(groupPrivilege.UpdatedAt).toEqual(mockGroupPrivilegeAttr.UpdatedAt);
45
+ expect(groupPrivilege.CreatedById).toEqual(mockGroupPrivilegeAttr.CreatedById);
46
+ expect(groupPrivilege.UpdatedById).toEqual(mockGroupPrivilegeAttr.UpdatedById);
47
+ }));
48
+ it('should throw ClassError when GroupPrivilegeAttr is not found', () => __awaiter(void 0, void 0, void 0, function* () {
49
+ const findOneMock = jest
50
+ .spyOn(group_privilege_repository_1.GroupPrivilegeRepository.prototype, 'findOne')
51
+ .mockResolvedValueOnce(null);
52
+ yield expect(group_privilege_1.GroupPrivilege.init(null, 1)).rejects.toThrow(general_1.ClassError);
53
+ expect(findOneMock).toBeCalledWith({
54
+ where: { GroupPrivilegeId: 1 },
55
+ transaction: null,
56
+ });
57
+ }));
58
+ it('should initialize with default values', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ const groupPrivilege = yield group_privilege_1.GroupPrivilege.init();
60
+ expect(groupPrivilege).toBeInstanceOf(group_privilege_1.GroupPrivilege);
61
+ expect(groupPrivilege.GroupPrivilegeId).toBeUndefined();
62
+ expect(groupPrivilege.GroupCode).toBeUndefined();
63
+ expect(groupPrivilege.PrivilegeCode).toBeUndefined();
64
+ expect(groupPrivilege.Status).toBeUndefined();
65
+ expect(groupPrivilege.CreatedAt).toBeUndefined();
66
+ expect(groupPrivilege.UpdatedAt).toBeUndefined();
67
+ expect(groupPrivilege.CreatedById).toBeUndefined();
68
+ expect(groupPrivilege.UpdatedById).toBeUndefined();
69
+ }));
70
+ });
71
+ //# sourceMappingURL=group-privilege.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-privilege.test.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/group-privilege/group-privilege.test.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ describe('LoginUser', () => {
2
+ it('should be true', () => {
3
+ expect(true).toBe(true);
4
+ });
5
+ });
6
+ //# sourceMappingURL=login-user.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-user.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/login-user/login-user.spec.ts"],"names":[],"mappings":"AAuuBA,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -436,10 +436,12 @@ class User extends general_1.UserBase {
436
436
  this.staffs = userAttr.staffs;
437
437
  }
438
438
  else {
439
+ console.error('User not found for email:', email);
439
440
  throw new general_1.ClassError('User', 'UserErrMsg0X', 'Invalid Credentials');
440
441
  }
441
442
  }
442
443
  if (this.ObjectId && this.Email !== email) {
444
+ console.error('Email mismatch:', this.Email, email);
443
445
  throw new Error('Invalid credentials.');
444
446
  }
445
447
  const check2FA = yield User.check2FA(this, dbTransaction);
@@ -456,6 +458,7 @@ class User extends general_1.UserBase {
456
458
  const passwordHashService = new password_hash_service_1.PasswordHashService();
457
459
  const isPasswordValid = yield passwordHashService.verify(password, this.Password);
458
460
  if (!isPasswordValid) {
461
+ console.error('Invalid password for user:', this.UserId);
459
462
  throw new Error('Invalid credentials.');
460
463
  }
461
464
  yield this.checkSystemAccess(this.UserId, system.SystemCode, dbTransaction);
@@ -511,6 +514,7 @@ class User extends general_1.UserBase {
511
514
  });
512
515
  const sessionName = config_1.ApplicationConfig.getComponentConfigValue('sessionName');
513
516
  if (!sessionName) {
517
+ console.error('Session name is not set in the configuration');
514
518
  throw new Error('Session name is not set in the configuration');
515
519
  }
516
520
  const userSession = yield this._SessionService.retrieveUserSession(this.ObjectId, sessionName);
@@ -563,6 +567,7 @@ class User extends general_1.UserBase {
563
567
  transaction: dbTransaction,
564
568
  });
565
569
  }
570
+ console.error('Login failed:', error);
566
571
  throw error;
567
572
  }
568
573
  });
@@ -596,13 +601,13 @@ class User extends general_1.UserBase {
596
601
  ],
597
602
  dbTransaction,
598
603
  });
599
- for (const usergroup of userGroups) {
604
+ outer: for (const usergroup of userGroups) {
600
605
  const group = usergroup.Group;
601
606
  const groupSystemAccess = yield User.getInheritedSystemAccess(dbTransaction, group);
602
607
  for (const system of groupSystemAccess) {
603
608
  if (system.SystemCode === systemCode) {
604
609
  isUserHaveAccess = true;
605
- break;
610
+ break outer;
606
611
  }
607
612
  }
608
613
  }
@@ -612,6 +617,7 @@ class User extends general_1.UserBase {
612
617
  }
613
618
  }
614
619
  catch (error) {
620
+ console.error('Error checking system access:', error);
615
621
  throw error;
616
622
  }
617
623
  });
@@ -1223,7 +1229,7 @@ class User extends general_1.UserBase {
1223
1229
  transaction: dbTransaction,
1224
1230
  });
1225
1231
  let systemAccesses = dataSystemAccesses;
1226
- if (group.InheritParentSystemAccessYN === 'Y' && group.ParentGroupCode) {
1232
+ if (group.InheritParentPrivilegeYN === 'Y' && group.ParentGroupCode) {
1227
1233
  const GroupCode = group.ParentGroupCode;
1228
1234
  const parentGroup = yield User._GroupRepo.findByPk(GroupCode, dbTransaction);
1229
1235
  const dataParentSystemAccesses = yield User.getInheritedSystemAccess(dbTransaction, parentGroup);