Skip to content

Commit 58ec90a

Browse files
chore: Handle forbidden username exceptions on registration (#1545)
1 parent 76e400f commit 58ec90a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/register/components/RegistrationFailure.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import PropTypes from 'prop-types';
99
import { windowScrollTo } from '../../data/utils';
1010
import {
1111
FORBIDDEN_REQUEST,
12+
FORBIDDEN_USERNAME,
1213
INTERNAL_SERVER_ERROR,
1314
TPA_AUTHENTICATION_FAILURE,
1415
TPA_SESSION_EXPIRED,
@@ -48,6 +49,9 @@ const RegistrationFailureMessage = (props) => {
4849
case TPA_SESSION_EXPIRED:
4950
errorMessage = formatMessage(messages['registration.tpa.session.expired'], { provider: context.provider });
5051
break;
52+
case FORBIDDEN_USERNAME:
53+
errorMessage = formatMessage(messages['registration.forbidden.username']);
54+
break;
5155
default:
5256
errorMessage = formatMessage(messages['registration.empty.form.submission.error']);
5357
break;

src/register/data/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export const FORM_SUBMISSION_ERROR = 'form-submission-error';
1111
export const INTERNAL_SERVER_ERROR = 'internal-server-error';
1212
export const TPA_AUTHENTICATION_FAILURE = 'tpa-authentication-failure';
1313
export const TPA_SESSION_EXPIRED = 'tpa-session-expired';
14+
export const FORBIDDEN_USERNAME = 'forbidden-username';

src/register/messages.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ const messages = defineMessages({
162162
defaultMessage: 'Registration using {provider} has timed out.',
163163
description: '',
164164
},
165+
'registration.forbidden.username': {
166+
id: 'registration.forbidden.username',
167+
defaultMessage: 'Usernames can\'t include words that could be mistaken for course roles. Please choose a different username.',
168+
description: '',
169+
},
165170
'registration.tpa.authentication.failure': {
166171
id: 'registration.tpa.authentication.failure',
167172
defaultMessage: 'We are sorry, you are not authorized to access {platform_name} via this channel. '

0 commit comments

Comments
 (0)