Show separate error messages for team key

Although using a team key is functionally the same as your service being
restricted, conflating the two errors is not helpful. What we typically
saw in research was that someone was using a team key, got the error,
used a live key and got the _same_ error.

This commit adds a new error message that specifically mentions the type
of API key that you’re using.
This commit is contained in:
Chris Hill-Scott
2016-08-10 15:54:53 +01:00
parent 0a429e18b4
commit ebfaa5dac2
2 changed files with 13 additions and 11 deletions

View File

@@ -270,11 +270,15 @@ def send_notification(notification_type):
[user.mobile_number, user.email_address] for user in service.users
)
):
raise InvalidRequest(
{'to': [(
if (api_user.key_type == KEY_TYPE_TEAM):
message = 'Cant send to this recipient using a team-only API key'
else:
message = (
'Cant send to this recipient when service is in trial mode '
' see https://www.notifications.service.gov.uk/trial-mode'
)]},
)
raise InvalidRequest(
{'to': [message]},
status_code=400
)