Skip to content

Commit 63a1531

Browse files
Fix and refactor logging in and out as different users (#549)
This makes some changes to: * unify the header across different user types * require you to be logged in as the right user type for different sections * add some short cuts for signing in as different user types * simplify how the organisation data is saved
1 parent a13d731 commit 63a1531

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+534
-570
lines changed

app/data/organisations.js

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4327,9 +4327,9 @@ module.exports = [
43274327
},
43284328
{
43294329
id: "RAP",
4330-
name: "North middlesex University Hospital NHS Trust",
4330+
name: "North Middlesex University Hospital NHS Trust",
43314331
address: {
4332-
line1: "North middlesex hospital",
4332+
line1: "13 Granary Way",
43334333
town: "London",
43344334
postcode: "N18 1QX"
43354335
},
@@ -6517,9 +6517,9 @@ module.exports = [
65176517
},
65186518
{
65196519
id: "RXX",
6520-
name: "Surrey and borders partnership NHS Foundation Trust",
6520+
name: "Surrey and Borders Partnership NHS Foundation Trust",
65216521
address: {
6522-
line1: "18 mole business park",
6522+
line1: "18 Mole Business park",
65236523
town: "Leatherhead",
65246524
postcode: "KT22 7AD"
65256525
},
@@ -8248,5 +8248,95 @@ module.exports = [
82488248
82498249
phone: "01234 567890"
82508250
}
8251+
},
8252+
{
8253+
id: "Y61",
8254+
name: "East of England",
8255+
type: "Region",
8256+
address: {
8257+
line1: "2-4 victoria house",
8258+
town: "cambridge",
8259+
postcode: "CB21 5XB"
8260+
}
8261+
},
8262+
{
8263+
id: "Y56",
8264+
name: "London",
8265+
type: "Region",
8266+
address: {
8267+
line1: "c/o nhs england",
8268+
town: "leeds",
8269+
postcode: "LS2 7UE"
8270+
}
8271+
},
8272+
{
8273+
id: "Y60",
8274+
name: "Midlands",
8275+
type: "Region",
8276+
address: {
8277+
line1: "2-4 victoria house",
8278+
town: "cambridge",
8279+
postcode: "CB21 5XB"
8280+
}
8281+
},
8282+
{
8283+
id: "Y63",
8284+
name: "North East and Yorkshire",
8285+
type: "Region",
8286+
address: {
8287+
line1: "c/o nhs england",
8288+
town: "leeds",
8289+
postcode: "LS2 7UA"
8290+
}
8291+
},
8292+
{
8293+
id: "Y62",
8294+
name: "North West",
8295+
type: "Region",
8296+
address: {
8297+
line1: "c/o nhs england",
8298+
town: "leeds",
8299+
postcode: "LS2 7UA"
8300+
},
8301+
inbox: [
8302+
{
8303+
id: "HKFFU48574",
8304+
fromOrganisationId: "FA424",
8305+
vaccinesRequested: ["flu"],
8306+
sentOn: "2025-06-22"
8307+
},
8308+
{
8309+
id: "PFU47263463",
8310+
fromOrganisationId: "FA02S",
8311+
vaccinesRequested: ["pertussis", "RSV"],
8312+
sentOn: "2025-06-24"
8313+
},
8314+
{
8315+
id: "OFU536369FUF",
8316+
fromOrganisationId: "PDL93",
8317+
vaccinesRequested: ["COVID-19"],
8318+
sentOn: "2025-06-25"
8319+
}
8320+
]
8321+
},
8322+
{
8323+
id: "Y59",
8324+
name: "South East",
8325+
type: "Region",
8326+
address: {
8327+
line1: "nhs england",
8328+
town: "leeds",
8329+
postcode: "LS2 7UE"
8330+
}
8331+
},
8332+
{
8333+
id: "Y58",
8334+
name: "South West",
8335+
type: "Region",
8336+
address: {
8337+
line1: "nhs england",
8338+
town: "leeds",
8339+
postcode: "LS2 7UE"
8340+
}
82518341
}
82528342
]

app/data/regions.js

Lines changed: 0 additions & 85 deletions
This file was deleted.

app/data/session-data-defaults.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
const allOrganisations = require('./all-organisations')
22
const featureFlags = require('./feature-flags')
33
const organisations = require('./organisations')
4-
const regions = require('./regions')
54
const users = require('./users')
65
const vaccines = require('./vaccines')
76

87
module.exports = {
98
organisations: organisations,
109
allOrganisations: allOrganisations,
11-
regions: regions,
1210
featureFlags: featureFlags,
1311
users: users,
1412
vaccines: vaccines,

app/data/users.js

Lines changed: 75 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,77 @@
11
module.exports = [
2+
// Jane Smith is the default signed in user
3+
// She's a lead admin for an NHS trust
4+
{
5+
"id": "2387441662601",
6+
"email": "[email protected]",
7+
"organisations": [
8+
{
9+
"id": "RW3",
10+
"permissionLevel": "Lead administrator",
11+
"status": "Active",
12+
"vaccinator": true
13+
}
14+
],
15+
"firstName": "Jane",
16+
"lastName": "Smith"
17+
},
18+
// Graham Wallace is a recorder at
19+
// multiple NHS Trusts (eg bank staff)
20+
{
21+
"id": "3283602393037",
22+
"email": "[email protected]",
23+
"organisations": [
24+
{
25+
"id": "RLR",
26+
"permissionLevel": "Recorder",
27+
"status": "Active",
28+
"vaccinator": true
29+
},
30+
{
31+
"id": "RXX",
32+
"permissionLevel": "Recorder",
33+
"status": "Active",
34+
"vaccinator": true
35+
},
36+
{
37+
"id": "RAP",
38+
"permissionLevel": "Recorder",
39+
"status": "Active",
40+
"vaccinator": true
41+
}
42+
],
43+
"firstName": "Graham",
44+
"lastName": "Wallace"
45+
},
46+
// Paulina Sloan is a lead admin for
47+
// a chain of pharmacies
248
{
349
"id": "9847489647892",
450
"email": "[email protected]",
551
"organisations": [
652
{
7-
"id": "RCY",
8-
"permissionLevel": "Administrator",
9-
"status": "Deactivated",
10-
"deactivatedDate": "2024-12-05",
11-
"vaccinator": true
53+
"id": "FA424",
54+
"permissionLevel": "Lead administrator",
55+
"status": "Active",
56+
"vaccinator": false
57+
},
58+
{
59+
"id": "FA02S",
60+
"permissionLevel": "Lead administrator",
61+
"status": "Active",
62+
"vaccinator": false
63+
},
64+
{
65+
"id": "FVJ99",
66+
"permissionLevel": "Lead administrator",
67+
"status": "Active",
68+
"vaccinator": false
69+
},
70+
{
71+
"id": "PDL93",
72+
"permissionLevel": "Lead administrator",
73+
"status": "Active",
74+
"vaccinator": false
1275
}
1376
],
1477
"firstName": "Paulina",
@@ -315,20 +378,6 @@ module.exports = [
315378
"firstName": "Kade",
316379
"lastName": "Ho"
317380
},
318-
{
319-
"id": "2387441662601",
320-
"email": "[email protected]",
321-
"organisations": [
322-
{
323-
"id": "RW3",
324-
"permissionLevel": "Lead administrator",
325-
"status": "Active",
326-
"vaccinator": true
327-
}
328-
],
329-
"firstName": "Jane",
330-
"lastName": "Smith"
331-
},
332381
{
333382
"id": "9524725216001",
334383
"email": "[email protected]",
@@ -13442,32 +13491,6 @@ module.exports = [
1344213491
"firstName": "Zuri",
1344313492
"lastName": "Wiggins"
1344413493
},
13445-
{
13446-
"id": "3283602393037",
13447-
"email": "[email protected]",
13448-
"organisations": [
13449-
{
13450-
"id": "RLR",
13451-
"permissionLevel": "Lead administrator",
13452-
"status": "Active",
13453-
"vaccinator": true
13454-
},
13455-
{
13456-
"id": "RXX",
13457-
"permissionLevel": "Lead administrator",
13458-
"status": "Active",
13459-
"vaccinator": true
13460-
},
13461-
{
13462-
"id": "RAP",
13463-
"permissionLevel": "Lead administrator",
13464-
"status": "Active",
13465-
"vaccinator": true
13466-
}
13467-
],
13468-
"firstName": "Wade",
13469-
"lastName": "Wallace"
13470-
},
1347113494
{
1347213495
"id": "6791828016461",
1347313496
"email": "[email protected]",
@@ -13731,5 +13754,12 @@ module.exports = [
1373113754
],
1373213755
"firstName": "Graeme",
1373313756
"lastName": "White"
13757+
},
13758+
{
13759+
"id": "66435353634",
13760+
"email": "[email protected]",
13761+
"firstName": "Sally",
13762+
"lastName": "Green",
13763+
admin: true
1373413764
}
1373513765
]

app/locals.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ module.exports =
1111
(req, res, next) => {
1212
res.locals.serviceName = config.serviceName
1313

14-
// Set currentUser and currentOrganisation for convenience
15-
res.locals.currentUser = req.session.data.users.find((user) => user.id === req.session.data.currentUserId);
16-
1714
// Set currentUser for convenience
18-
res.locals.currentOrganisation = req.session.data.organisations.find((organisation) => organisation.id === req.session.data.currentOrganisationId);
19-
20-
// set current logged in region
21-
res.locals.currentRegion = req.session.data.regions.find((region) => region.id === req.session.data.currentRegionId);
15+
if (req.session.data.currentUserId) {
16+
res.locals.currentUser = req.session.data.users.find((user) => user.id === req.session.data.currentUserId)
17+
} else {
18+
res.locals.currentUser = null
19+
}
20+
21+
// Set currentOrganisation for convenience
22+
if (req.session.data.currentOrganisationId) {
23+
res.locals.currentOrganisation = req.session.data.organisations.find((organisation) => organisation.id === req.session.data.currentOrganisationId)
24+
} else {
25+
res.locals.currentOrganisation = null
26+
}
2227

2328
next()
2429
}

0 commit comments

Comments
 (0)