Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Handle and i18n M_THREEPID_IN_USE during registration (#6986)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 19, 2021
1 parent 9c78671 commit a9c27e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/structures/auth/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default class Registration extends React.Component<IProps, IState> {

private onUIAuthFinished = async (success: boolean, response: any) => {
if (!success) {
let msg = response.message || response.toString();
let errorText = response.message || response.toString();
// can we give a better error message?
if (response.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
const errorTop = messageForResourceLimitError(
Expand All @@ -291,7 +291,7 @@ export default class Registration extends React.Component<IProps, IState> {
'': _td("Please <a>contact your service administrator</a> to continue using this service."),
},
);
msg = <div>
errorText = <div>
<p>{ errorTop }</p>
<p>{ errorDetail }</p>
</div>;
Expand All @@ -301,15 +301,18 @@ export default class Registration extends React.Component<IProps, IState> {
msisdnAvailable = msisdnAvailable || flow.stages.includes('m.login.msisdn');
}
if (!msisdnAvailable) {
msg = _t('This server does not support authentication with a phone number.');
errorText = _t('This server does not support authentication with a phone number.');
}
} else if (response.errcode === "M_USER_IN_USE") {
msg = _t("That username already exists, please try another.");
errorText = _t("That username already exists, please try another.");
} else if (response.errcode === "M_THREEPID_IN_USE") {
errorText = _t("That e-mail address is already in use.");
}

this.setState({
busy: false,
doingUIAuth: false,
errorText: msg,
errorText,
});
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,7 @@
"Registration has been disabled on this homeserver.": "Registration has been disabled on this homeserver.",
"This server does not support authentication with a phone number.": "This server does not support authentication with a phone number.",
"That username already exists, please try another.": "That username already exists, please try another.",
"That e-mail address is already in use.": "That e-mail address is already in use.",
"Continue with %(ssoButtons)s": "Continue with %(ssoButtons)s",
"%(ssoButtons)s Or %(usernamePassword)s": "%(ssoButtons)s Or %(usernamePassword)s",
"Already have an account? <a>Sign in here</a>": "Already have an account? <a>Sign in here</a>",
Expand Down

0 comments on commit a9c27e2

Please sign in to comment.