Skip to content

Commit e8dcc0a

Browse files
fix issue with unathorised role handling (#665)
1 parent cb449d7 commit e8dcc0a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

app/src/pages/unauthorisedLoginPage/UnauthorisedLoginPage.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ describe('UnauthorisedLoginPage', () => {
3131
'In order to keep patient information safe, only authorised accounts can access this service',
3232
'This includes:',
3333
'GP practice staff who work at the practice the patient is registered with who have one of these roles on their smart cards:',
34-
'GP Admin Role: R8010, R8013, R1790, R8008',
35-
'GP Clinical Role: R8000',
34+
'GP Admin Role:',
35+
'R8010, R8013, R1790, R8008',
36+
'GP Clinical Role:',
37+
'R8000',
3638
'PCSE staff where a patient does not have an active registration',
3739
"If you don't have access and feel you should have, please contact your local Registration Authority",
3840
];

app/src/pages/unauthorisedLoginPage/UnauthorisedLoginPage.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { routes } from '../../types/generic/routes';
22
import { useNavigate, useLocation } from 'react-router-dom';
33
import { ButtonLink } from 'nhsuk-react-components';
4-
import React from 'react';
54
import useTitle from '../../helpers/hooks/useTitle';
65

76
const UnauthorisedLoginPage = () => {
@@ -10,8 +9,10 @@ const UnauthorisedLoginPage = () => {
109
const location = useLocation();
1110
const errorData = location.state?.errorData;
1211
useTitle({ pageTitle: 'Unauthorised account' });
13-
const gpAdminRoles = errorData.roles[0];
14-
const gpClinicalRoles = errorData.roles[1];
12+
13+
const gpAdminRoles = errorData.roles[0].split(',').join(', ');
14+
const gpClinicalRoles = errorData.roles[1].split(',').join(', ');
15+
1516
return (
1617
<>
1718
<h1>{pageHeader}</h1>
@@ -31,8 +32,12 @@ const UnauthorisedLoginPage = () => {
3132
have one of these roles on their smart cards:
3233
<br />
3334
<br />
34-
<p>GP Admin Role: {gpAdminRoles}</p>
35-
<p>GP Clinical Role: {gpClinicalRoles}</p>
35+
<p>
36+
<strong>GP Admin Role:</strong> {gpAdminRoles}
37+
</p>
38+
<p>
39+
<strong>GP Clinical Role:</strong> {gpClinicalRoles}
40+
</p>
3641
</li>
3742
<li>PCSE staff where a patient does not have an active registration</li>
3843
</ul>

lambdas/handlers/token_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ def lambda_handler(event, context):
5454
"GET",
5555
).create_api_gateway_response()
5656
except LoginException as e:
57-
if e.error == LambdaError.LoginNoRole:
57+
if e.status_code == 401:
5858
allowed_roles = (
5959
login_service.token_handler_ssm_service.get_smartcard_role_codes()
6060
)
6161
body = LambdaError.LoginNoRole.create_error_body(roles=allowed_roles)
6262
return ApiGatewayResponse(
63-
401,
63+
e.status_code,
6464
body,
6565
"GET",
6666
).create_api_gateway_response()

0 commit comments

Comments
 (0)