-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OGD invite user flow #1239
Open
shaed-parkar
wants to merge
273
commits into
master
Choose a base branch
from
development/GA/OGD-73-Invite-User-Flow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,660
−393
Open
OGD invite user flow #1239
Changes from all commits
Commits
Show all changes
273 commits
Select commit
Hold shift + click to select a range
b0ae207
fix failing test
codaimaster 54d59a8
fix failing build
codaimaster 9d335c3
skip test:a11y as it's broken
codaimaster 1a9a764
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 ad2f0bd
Bumping chart version/ fixing aliases
hmcts-jenkins-j-to-z[bot] cf69998
EXUI-803: Use ccpay-web-component's
MunishSharmaHMCTS 212c45b
Merge pull request #1134 from hmcts/EXUI-803-CcpayWebComponentUpgraded
olusegz07 f460ca7
EMUI-803: chart 2.4.18 is deprecated, upgraded to at least 3.0.0
MunishSharmaHMCTS 6624276
setting functionality use 18
MunishSharmaHMCTS dd15a64
changes for functional tests
MunishSharmaHMCTS fb76eb0
Merge pull request #1137 from hmcts/EXUI-803-CcpayWebComponentUpgraded
olusegz07 ffdda23
more logging
MunishSharmaHMCTS a71ab4a
functional test fixes
MunishSharmaHMCTS a216ee4
removed mocking client
MunishSharmaHMCTS 6ee93fc
diable parallel execution
MunishSharmaHMCTS 35c9b20
Merge pull request #1138 from hmcts/EXUI-803-CcpayWebComponentUpgraded
MunishSharmaHMCTS edcd45f
task: EXUI-804 - ccd ui toolkit's upgraded version added
olusegz07 d5d4618
Added yarn stable version
olusegz07 23f9243
yarn audit file updated
olusegz07 853d5f5
Merge pull request #1145 from hmcts/fix/EXUI-847-yarn-audit-file
olusegz07 fe98716
yarn audit file updated
olusegz07 93c21dc
Fix broken jenkin build
olusegz07 399a606
code tidy
olusegz07 debeec8
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 72a4621
fixed issues with merge from master branch
olusegz07 0025a04
Update localServer.ts
olusegz07 804f53c
Ignore test due failing address lookup failing for the new feature added
olusegz07 7260f7f
Bumping chart version/ fixing aliases
hmcts-jenkins-j-to-z[bot] d78fed5
Update yarn-audit-known-issues
olusegz07 b781201
Merge branch 'EXUI-628_EXUI-634_upgrade-node18-and-ng15' of https://g…
olusegz07 a803b8f
Code tidy
olusegz07 f9b32f4
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 1f25833
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 54ad2ac
package.json updated
olusegz07 7156cd7
toolkit version update
olusegz07 bac1602
fix -EXUI-1030 - styling resolved
olusegz07 79dd3ac
code tidy
olusegz07 f8ab1b9
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 ae1d73f
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 f99588b
toolkit version update
olusegz07 3422491
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 7433ace
Update yarn-audit-known-issues
olusegz07 caac76f
ccpay-web-component version updated
olusegz07 9bdd935
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
olusegz07 7fec49f
toolkit version update
olusegz07 16cf13d
yarn-audit update
olusegz07 187310c
yarn audit update
olusegz07 16dfac2
library version update
olusegz07 e325a8b
toolkit version
olusegz07 66a0a71
enable all tests and fix broken setup (#1216)
shaed-parkar 9a4f418
Merge branch 'master' into EXUI-628_EXUI-634_upgrade-node18-and-ng15
andywilkinshmcts 1db078b
Update user loading
Josh-HMCTS 3499698
Initial commit
TomForniCGI 50abf5e
GA-31 Update the organisation model to include the profileids propert…
shaed-parkar fb2f7b5
GA-90 Add a shell manage user container component
b974ca9
Update yarn-audit-known-issues
olusegz07 ce177ff
GA-88 subscribe to the ogd-invite-user-flow feature toggle (#1218)
shaed-parkar d48835a
GA-89 create ogd user invite flow guard (#1221)
shaed-parkar d8a46bd
Generated new components for profile specific content
ben-james-hmcts 731f00f
Updated content within components - No accordion added currently as G…
ben-james-hmcts 1081890
Added instruction comments for when to display each component
ben-james-hmcts 4949b2e
Fixed lint errors
ben-james-hmcts c793f49
removed scss files for new components as not required
ben-james-hmcts 7c8a0a2
removed scss files for new components as not required
ben-james-hmcts dd903e2
Removed test files for new components as not required
ben-james-hmcts 8a3e65e
Merge pull request #1222 from hmcts/development/GA/GA-82-create-profi…
ben-james-hmcts 3129264
NgRx Changes
TomForniCGI cc4c5d2
Remove comment in searchFilter spec file
Josh-HMCTS 8bb4cda
GA-90 Add a shell manage user container component
28fbd14
GA-88 subscribe to the ogd-invite-user-flow feature toggle (#1218)
shaed-parkar 50fd11f
GA-89 create ogd user invite flow guard (#1221)
shaed-parkar 52ff33d
Generated new components for profile specific content
ben-james-hmcts 2877f51
Updated content within components - No accordion added currently as G…
ben-james-hmcts f451cf6
Added instruction comments for when to display each component
ben-james-hmcts d56fb52
Fixed lint errors
ben-james-hmcts 7621769
removed scss files for new components as not required
ben-james-hmcts 2c16941
removed scss files for new components as not required
ben-james-hmcts 848f680
Removed test files for new components as not required
ben-james-hmcts a2607aa
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into feature/GA-44
Josh-HMCTS 471c9a6
Fix merge bugs,
Josh-HMCTS 1cac975
Made changes from comments
TomForniCGI 9340ace
GA-75 manage user additional access checkboxes from organisation (#1223)
shaed-parkar 57ea5de
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into feature/GA-44
Josh-HMCTS bb61cc9
Added 6 new components for static content for each of the OGD profiles
ben-james-hmcts a68ef77
Update searchFilter to use xui-common-lib select
Josh-HMCTS 8abc2cc
Match pre-existing style
Josh-HMCTS 1b15ccd
Merge pull request #1227 from hmcts/development/GA/GA-96-Additional-P…
ben-james-hmcts c639e86
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into feature/GA-44
Josh-HMCTS 4a63bba
Remove duplicate load call from user.component
Josh-HMCTS 94f208c
Merge pull request #1217 from hmcts/feature/GA-44
Josh-HMCTS 3c01da3
Update search container styling
Josh-HMCTS d67140e
updated terraform and azurerm version
cpareek 0be6fa8
Changed from User to Organisation
TomForniCGI 0d4be38
Housekeeping
TomForniCGI dc1c80f
Housekeeping
TomForniCGI 9de8d41
Merge remote-tracking branch 'origin/development/GA/OGD-73-Invite-Use…
TomForniCGI 10375ac
Dispatch loadOrganisationProfileIds
TomForniCGI 9937fb4
Linting Issues Fixed
TomForniCGI beae772
GA-95 user details section for manage user (#1229)
shaed-parkar 8fe237c
Created new model for edit user
ben-james-hmcts ddc6a32
Changes to editUserRolesObj to work with new strongly typed edit user…
ben-james-hmcts 4d4a2c6
Amended editUser constructor to be strongly typed to the new edit use…
ben-james-hmcts c5397f5
Merge branch 'development/GA/OGD-73-Invite-User-Flow' of github.com:h…
ben-james-hmcts a85e6eb
GA-96 update profile into accordions (#1230)
shaed-parkar 3e2e17d
invite user button redirect to new manage user component when ogd tog…
shaed-parkar 84cc4cc
Merge remote-tracking branch 'origin/development/GA/OGD-73-Invite-Use…
TomForniCGI e6b12b0
Updated userid to just id due to model change from user to inviteUser
ben-james-hmcts 1530d7c
Made a start on manage user submit code - paused to do some BA checks…
ben-james-hmcts c2dd057
Merge branch 'development/GA/OGD-73-Invite-User-Flow' of github.com:h…
ben-james-hmcts a9d0274
Error Handling
TomForniCGI bfa36d0
Yarn audit
TomForniCGI adf3b22
Housekeeping
TomForniCGI d62dc5a
Changes to 5xx error handling
TomForniCGI 8a15b52
Right Jurisdiction model
TomForniCGI 9f6e4f5
prompt validation on submit
143fd32
bugfix logger to include additional params for debug
e97c030
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into GA-62
shaed-parkar 9e3a0df
Merge pull request #1224 from hmcts/GA-62
TomForniCGI 0e95180
Add access types to invite user post
Josh-HMCTS d20bb97
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS d8d5b87
add missing tests
Josh-HMCTS 021885f
GA-121 accessibility fixes (#1236)
shaed-parkar 905b0e3
update to error handling
Josh-HMCTS f52363d
Fixed bug in logger
ben-james-hmcts 428293f
Corrected roles types on edituser model and edited mapedituserroles m…
ben-james-hmcts 9fb761b
Added updateUser method and corrected a number of bugs in manage user…
ben-james-hmcts 015b436
Added initial test for update user on manage user component
ben-james-hmcts 99d76cd
Merge branch 'master' into development/GA/OGD-73-Invite-User-Flow
66b17b0
fix linting warnings form ogd changes
3af220c
Additional changes to correct unit tests
ben-james-hmcts 30d7c0e
fix test setup up
27bc71e
GA-125 ogd successful update page (#1244)
shaed-parkar 8ff08c8
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
ben-james-hmcts c6ff67d
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS 1624fb8
Added several subscribes for edit user return actions
ben-james-hmcts e8a0760
Amended vars being passed to PUT method to line up with new model bei…
ben-james-hmcts f98c9dc
Committing my TODO comments to allow reviews to understand work still…
ben-james-hmcts 2bcde8e
added check for changes to a const to improve code legibility
ben-james-hmcts cecc047
Various fixes in unit tests to mock forms, now required to pass the o…
ben-james-hmcts 74d9ec7
Removed tick import, no longer required
ben-james-hmcts d926f5b
Removed userId var from mapEditUserRoles method as it is contained wi…
ben-james-hmcts 7f846b5
Removed focus from my tests to ensure all tests run
ben-james-hmcts 2b0a74c
Added EditUserModel type to the editUser param to ensure all calls to…
ben-james-hmcts 1c9a456
Amended version of xui common lib to latest pre release
ben-james-hmcts 2d350db
Minor bug fixes, null checks, etc
ben-james-hmcts e85526f
fixed indentation
ben-james-hmcts 0d73bcf
Getting feature flag from store instead of feature toggle service for…
ben-james-hmcts 4551d28
Corrected version of xui common lib
ben-james-hmcts 6b71b94
commit missing lock file
22cb6d6
Fixed a number of tests broken due to method param changes on mapEdit…
ben-james-hmcts c44b410
Added userId param back to mapEditUserRoles method as we cannot guara…
ben-james-hmcts c434ad8
Corrected rolesAdd and rolesDelete objects for unit test
ben-james-hmcts 6f65d1c
mock user fix to resolve failing tests
sreekanthpuligadda 475443f
Add refresh user API endpoint and corresponding actions and effects t…
shaed-parkar 68e1a39
Merge pull request #1245 from hmcts/development/GA/OGD-86-Update-Exis…
ben-james-hmcts 4f49218
add in access types comparison function, updates save code to call co…
Josh-HMCTS bb652a9
move hardcoded values out of component into node api
shaed-parkar d1f4504
add null operator to handle new user flow
7b710d5
fix form check
49657a6
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS 8ee2e44
Merge pull request #1238 from hmcts/development/GA/GA-101
Josh-HMCTS 2c578e6
GA-130 update selectors for next user pagination (#1252)
shaed-parkar 7bbccbc
update typeahead to sort alphabetically
Josh-HMCTS 62fb874
bugfixes for reinvite
75d7f89
resolve review comments
Josh-HMCTS 8c24849
GA-61 Map access profile data to AccessType selection checkboxes for …
TomForniCGI d156daf
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS b237e43
deploy
Josh-HMCTS c2d5ee1
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS e3500e6
Merge branch 'master' into development/GA/OGD-73-Invite-User-Flow
sanjayparekh-hmcts c429016
update search component for bugs found
Josh-HMCTS 55eaeea
GA-44-FunctionalTests
poojithanag 55d2bfd
Merge pull request #1253 from hmcts/development/GA/GA-128
Josh-HMCTS 1d11289
rename, cleanup
Josh-HMCTS 38965fc
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS eed7aad
fix unit test
Josh-HMCTS 45683d6
update models from acccessTypes to userAccessTypes after initial inte…
shaed-parkar eb108cd
Resolve search bug
Josh-HMCTS 4ae3fb8
update yarn audit
Josh-HMCTS 4e374dd
fix filtering bug on input change
Josh-HMCTS 022147c
fix unit test
Josh-HMCTS 0fa51f2
GA-61-B (#1254)
TomForniCGI a1630af
Amended accessTypes to userAccessTypes for editUserModel
ben-james-hmcts a68176d
Added new component for manage user failure
ben-james-hmcts 09bea66
Merge branch 'development/GA/OGD-73-Invite-User-Flow' of github.com:h…
ben-james-hmcts f2b5332
add new ngrx action to check if user list available on user-details page
Josh-HMCTS b62fc71
Reset edit user failure upon hitting the failure page (copied from pr…
ben-james-hmcts 4920d74
Check for 500 response from API and throw edit user failure
ben-james-hmcts ef078e3
Add route to new manage user failure component
ben-james-hmcts 52a0760
Call new manage user failure route if edit user failure comes back true
ben-james-hmcts dbd6e24
Additional code to fix unit tests
ben-james-hmcts cec5bc2
Removed import detected by lint as not required
ben-james-hmcts cf5c21c
update access-type api to remove dummy data and point to backend
Josh-HMCTS 5e7e8ab
Minor change to trigger build on PR
ben-james-hmcts b7fd76f
Updated yarn known issues file as flagged by jenkins build
ben-james-hmcts 941b04e
Added manageUserFailureComponent to component exports
ben-james-hmcts 7fec0fe
Merge branch 'development/GA/GA-59' into development/GA/OGD-73-Integr…
Josh-HMCTS ecd8cad
Fixed unit test for manage user failure component
ben-james-hmcts d276f98
Merge pull request #1265 from hmcts/development/GA/OGD-86-Update-Exis…
ben-james-hmcts 4a9389f
Update profileIds to use constants
Josh-HMCTS e2296e0
Remove left padding on GA info panels, fix typo on solicitor profile …
Josh-HMCTS 63e522f
Update organisation profileIds to retrieve from loadAllUsersNoRoleDat…
Josh-HMCTS db2d273
Update model/implementation for retrieveAccessTypes enpoint
Josh-HMCTS a72eed2
update yarn audit
Josh-HMCTS bc21810
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS 47b706f
update yarn audit
Josh-HMCTS 59d5541
Merge pull request #1264 from hmcts/development/GA/manage-user-refresh
Josh-HMCTS 4952776
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS 29214be
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS 57d2bb0
Dont show roles on user details if the access type display set to false
Josh-HMCTS 19ee6bd
Rework OGD invite/edit to be handled in single node endpoint
Josh-HMCTS ee2d617
Merge branch 'master' into development/GA/OGD-73-Invite-User-Flow
Josh-HMCTS 4a5203a
GA-127 update profile accordion text and style for manage user form
shaed-parkar cdb8d57
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS dfd26b0
code reviews
Josh-HMCTS c94f1fe
update yarn audit
Josh-HMCTS 2d1e7e7
Merge pull request #1255 from hmcts/development/GA/Bug-GA-44
Josh-HMCTS 4ba553f
Merge branch 'master' into development/GA/OGD-73-Invite-User-Flow
shaed-parkar d1c58ec
Merge branch 'development/GA/OGD-73-Invite-User-Flow' into developmen…
Josh-HMCTS 3cbca55
Merge pull request #1270 from hmcts/development/GA/OGD-73-Integration
Josh-HMCTS 96b50b9
Add CCD Definition Store API path
e69bc98
Bumping chart version/ fixing aliases
hmcts-jenkins-j-to-z[bot] ad6db6b
Update copy and OGD flow
Josh-HMCTS 4776d20
temp remove refresh user call
Josh-HMCTS 967323e
Merge pull request #1272 from hmcts/development/GA/OGD-183
Josh-HMCTS f6ae937
fix roles on edit
Josh-HMCTS c16bdba
readd refresh-user endpoint
Josh-HMCTS bb7c3ea
uncomment api call to refresh user
Josh-HMCTS 7018769
yarn audit
Josh-HMCTS fed0273
move userID for refresh call to req param
Josh-HMCTS 56b373f
yarn audit
Josh-HMCTS d9fc77e
add userId as param
Josh-HMCTS ee3446f
Resolve review comments - Olu
Josh-HMCTS d5bc05f
Merge branch 'master' into development/GA/OGD-73-Invite-User-Flow
Josh-HMCTS f13b896
Code review comments - Andy
Josh-HMCTS 58d56cf
Resolve typos on 'onDestroy'
Josh-HMCTS ee3cb24
Fix unit test
Josh-HMCTS 7c9f5ff
Add org-role-mapping endpoint for refresh-user call
Josh-HMCTS 3357919
Resolve edge case where user would be blocked from loading organisati…
Josh-HMCTS fe116c6
resolve edge case where users selection can override mandatory access…
Josh-HMCTS bed5a3b
remove console logs, adjust ogd enpoints to point to right role
Josh-HMCTS 59a6586
Added new test for the new update user functionality - copied all oth…
ben-james-hmcts a47a79c
Merge branch 'master' into development/GA/OGD-73-Invite-User-Flow
shaed-parkar e1d067a
update audit file
9c4e93a
Refactor UsersEffects to conditionally load data based on feature flag
99cfc6b
Merge bugfixes for GA-101
b7a4bf7
fix linting
925f77b
fix linting
53f8c9f
Update nodejs dependency version to 3.1.0
85a9d3a
GA OGD Functional Tests (#1284)
shaed-parkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Request, Response, Router } from 'express'; | ||
import { compareAccessTypes } from '../retrieveAccessTypes'; | ||
import { inviteUserRouteOGD } from '../inviteUser'; | ||
import { ogdEditUserRoute } from '../editUserPermissions'; | ||
import { refreshUser } from '../refresh-user'; | ||
import * as log4jui from '../lib/log4jui'; | ||
|
||
export const router = Router({ mergeParams: true }); | ||
const logger = log4jui.getLogger('OGD-FLOW'); | ||
|
||
export async function ogdInvite(req: Request, res: Response) { | ||
try { | ||
logger.info('ogdInvite:: Invite Request received'); | ||
const userPayload = req.body.userPayload; | ||
if (userPayload.roles.includes('pui-case-manager')) { | ||
const compareResult = await compareAccessTypes(req); | ||
req.body.userPayload = { ...userPayload, ...compareResult }; | ||
} | ||
const operationResult = await inviteUserRouteOGD(req); | ||
const userId = operationResult.userIdentifier; | ||
req.body = { userId }; | ||
await refreshUser(req); | ||
res.send(operationResult); | ||
} catch (error) { | ||
logger.error('ogdInvite:: Error ', error); | ||
res.status(error.apiStatusCode || 500).json(error); | ||
} | ||
} | ||
|
||
export async function ogdUpdate(req: Request, res: Response) { | ||
try { | ||
logger.info('ogdUpdate:: Edit User Request received'); | ||
const userPayload = req.body.userPayload; | ||
const userId = req.params.userId; | ||
if (userPayload.userAccessTypes.length > 0) { | ||
const compareResult = await compareAccessTypes(req); | ||
req.body = { ...userPayload, ...compareResult }; | ||
} else { | ||
req.body = userPayload; | ||
} | ||
const operationResult = await ogdEditUserRoute(req); | ||
req.body = { userId }; | ||
await refreshUser(req); | ||
res.send(operationResult); | ||
} catch (error) { | ||
logger.error('ogdUpdate:: Error ', error); | ||
res.status(error.apiStatusCode || 500).json(error); | ||
} | ||
} | ||
|
||
router.post('/invite', ogdInvite); | ||
router.put('/update/:userId', ogdUpdate); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Request, Router } from 'express'; | ||
import { getConfigValue } from '../configuration'; | ||
import { SERVICES_ROLE_ASSIGNMENT_MAPPING_API_PATH } from '../configuration/references'; | ||
import * as log4jui from '../lib/log4jui'; | ||
import { exists, valueOrNull } from '../lib/util'; | ||
|
||
const logger = log4jui.getLogger('refresh-user'); | ||
|
||
export async function refreshUser(req: Request) { | ||
const payload = req.body; | ||
try { | ||
const serviceApiBasePath = getConfigValue(SERVICES_ROLE_ASSIGNMENT_MAPPING_API_PATH); | ||
const userId = payload.userId; | ||
const reqUrl = `${serviceApiBasePath}/am/role-mapping/professional/refresh?userId=${userId}`; | ||
logger.info('REFRESH USER: request URL:: ', reqUrl); | ||
const response = await req.http.post(reqUrl); | ||
logger.info('response::', response.data); | ||
return response.data; | ||
} catch (error) { | ||
logger.error('error', error); | ||
const status = exists(error, 'status') ? error.status : 500; | ||
const errReport = { | ||
apiError: valueOrNull(error, 'data.errorMessage'), | ||
apiStatusCode: status, | ||
message: valueOrNull(error, 'data.errorDescription') | ||
}; | ||
throw (errReport); | ||
} | ||
} | ||
|
||
export const router = Router({ mergeParams: true }); | ||
router.post('/', refreshUser); | ||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Function to compare the users accessType selections with the most recently obtained ones | ||
export function processAccessTypes(currentOrganisationAccessTypes, userAccessTypeOptions) { | ||
const processedAccessTypes = []; | ||
const accessTypesMap = new Map(); | ||
currentOrganisationAccessTypes.forEach((jurisdiction) => { | ||
jurisdiction.accessTypes.forEach((accessType) => { | ||
const key = `${jurisdiction.jurisdictionId}-${accessType.organisationProfileId}-${accessType.accessTypeId}`; | ||
accessTypesMap.set(key, accessType); | ||
}); | ||
}); | ||
|
||
userAccessTypeOptions.userAccessTypes.forEach((userAccessType) => { | ||
const key = `${userAccessType.jurisdictionId}-${userAccessType.organisationProfileId}-${userAccessType.accessTypeId}`; | ||
const accessType = accessTypesMap.get(key); | ||
|
||
if (accessType && accessType.display) { | ||
if (accessType.accessMandatory && accessType.accessDefault) { | ||
// If access type is mandatory and default is true, set it to true | ||
processedAccessTypes.push({ | ||
jurisdictionId: userAccessType.jurisdictionId, | ||
organisationProfileId: userAccessType.organisationProfileId, | ||
accessTypeId: userAccessType.accessTypeId, | ||
enabled: true | ||
}); | ||
} else { | ||
// For non-mandatory access types or mandatory with default false, use user's selection | ||
processedAccessTypes.push(userAccessType); | ||
} | ||
} | ||
|
||
// Remove the processed access type from the map | ||
accessTypesMap.delete(key); | ||
}); | ||
|
||
accessTypesMap.forEach((accessType, key) => { | ||
if (accessType.display) { | ||
const [jurisdictionId, organisationProfileId, accessTypeId] = key.split('-'); | ||
processedAccessTypes.push({ | ||
jurisdictionId, | ||
organisationProfileId, | ||
accessTypeId, | ||
enabled: accessType.accessDefault | ||
}); | ||
} | ||
}); | ||
|
||
return { | ||
...userAccessTypeOptions, | ||
userAccessTypes: processedAccessTypes | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Request, Response, Router } from 'express'; | ||
import { getConfigValue } from '../configuration'; | ||
import { SERVICES_CCD_DEFINITION_STORE_API_PATH } from '../configuration/references'; | ||
import * as log4jui from '../lib/log4jui'; | ||
import { exists, valueOrNull } from '../lib/util'; | ||
import { processAccessTypes } from './accessTypesComparison'; | ||
|
||
const logger = log4jui.getLogger('retrive-access-types'); | ||
|
||
async function fetchAccessTypes(req: Request, payload: any): Promise<any> { | ||
try { | ||
const ccdDefinitionStore = getConfigValue(SERVICES_CCD_DEFINITION_STORE_API_PATH); | ||
const url = `${ccdDefinitionStore}/retrieve-access-types`; | ||
logger.info('RETRIEVE ACCESS TYPES: request URL:: ', url); | ||
const response = await req.http.post(url, payload); | ||
return response.data; | ||
} catch (error) { | ||
logger.error(error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function handleRetrieveAccessTypes(req: Request, res: Response) { | ||
const payload = req.body; | ||
try { | ||
const data = await fetchAccessTypes(req, payload); | ||
res.send(data); | ||
} catch (error) { | ||
const status = exists(error, 'status') ? error.status : 500; | ||
const errReport = { | ||
apiError: valueOrNull(error, 'data.errorMessage'), | ||
apiStatusCode: status, | ||
message: valueOrNull(error, 'data.errorDescription') | ||
}; | ||
res.status(status).send(errReport); | ||
} | ||
} | ||
|
||
export async function compareAccessTypes(req: Request) { | ||
try { | ||
const orgIdPayload = { organisationProfileIds: req.body.orgIdsPayload }; | ||
const userAccessTypesPayload = req.body.userPayload; | ||
const accessTypes = await fetchAccessTypes(req, orgIdPayload); | ||
const comparedUserSelections = processAccessTypes(accessTypes.jurisdictions, userAccessTypesPayload); | ||
return (comparedUserSelections); | ||
} catch (error) { | ||
logger.error('Error in compareAccessTypes:', error); | ||
return ({ error: 'An error occurred while processing your request.' }); | ||
} | ||
} | ||
|
||
export const router = Router({ mergeParams: true }); | ||
|
||
router.post('/', handleRetrieveAccessTypes); | ||
router.post('/compare', compareAccessTypes); | ||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you verified that these changes are overriden by the "production" config section below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes