Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error message when domain is not allowed on Tchap #512

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions patches/patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
},
"registration-for-mainlining": {
"package": "matrix-react-sdk",
"comments": "registration process is customized",
"github-issue": "https://github.com/tchapgouv/tchap-web-v4/issues/460",
"files": [
"src/components/structures/auth/Registration.tsx",
"src/components/views/auth/RegistrationForm.tsx"
Expand Down
24 changes: 17 additions & 7 deletions patches/registration-for-mainlining/matrix-react-sdk+3.68.0.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
diff --git a/node_modules/matrix-react-sdk/src/components/structures/auth/Registration.tsx b/node_modules/matrix-react-sdk/src/components/structures/auth/Registration.tsx
index dd9be19..4226280 100644
index dd9be19..144efa3 100644
--- a/node_modules/matrix-react-sdk/src/components/structures/auth/Registration.tsx
+++ b/node_modules/matrix-react-sdk/src/components/structures/auth/Registration.tsx
@@ -39,8 +39,10 @@ import InteractiveAuth, { InteractiveAuthCallback } from "../InteractiveAuth";
@@ -39,8 +39,11 @@ import InteractiveAuth, { InteractiveAuthCallback } from "../InteractiveAuth";
import Spinner from "../../views/elements/Spinner";
import { AuthHeaderDisplay } from "./header/AuthHeaderDisplay";
import { AuthHeaderProvider } from "./header/AuthHeaderProvider";
+import { AuthHeaderModifier } from './header/AuthHeaderModifier'; // :TCHAP:
import SettingsStore from "../../../settings/SettingsStore";
import { ValidatedServerConfig } from "../../../utils/ValidatedServerConfig";
+import TchapUtils from '../../../../../../src/util/TchapUtils'; // :TCHAP:
+import TchapUrls from "../../../../../../src/util/TchapUrls";

const debuglog = (...args: any[]): void => {
if (SettingsStore.getValue("debug_registration")) {
@@ -277,11 +279,22 @@ export default class Registration extends React.Component<IProps, IState> {
@@ -277,11 +280,22 @@ export default class Registration extends React.Component<IProps, IState> {
}

private onFormSubmit = async (formVals: Record<string, string>): Promise<void> => {
Expand All @@ -36,7 +37,7 @@ index dd9be19..4226280 100644
});
};

@@ -296,7 +309,10 @@ export default class Registration extends React.Component<IProps, IState> {
@@ -296,7 +310,10 @@ export default class Registration extends React.Component<IProps, IState> {
emailAddress,
clientSecret,
sendAttempt,
Expand All @@ -48,7 +49,16 @@ index dd9be19..4226280 100644
client_secret: clientSecret,
hs_url: this.state.matrixClient.getHomeserverUrl(),
is_url: this.state.matrixClient.getIdentityServerUrl(),
@@ -476,6 +492,11 @@ export default class Registration extends React.Component<IProps, IState> {
@@ -341,6 +358,8 @@ export default class Registration extends React.Component<IProps, IState> {
errorText = _t("Someone already has that username, please try another.");
} else if (response instanceof MatrixError && response.errcode === "M_THREEPID_IN_USE") {
errorText = _t("That e-mail address or phone number is already in use.");
+ } else if (response instanceof MatrixError && response.errcode === "M_THREEPID_DENIED") {
+ errorText = _t("That email is not allowed on Tchap", {}, {a: (sub)=><a href={TchapUrls.requestDomainUrl}>{sub}</a>});
}

this.setState({
@@ -476,6 +495,11 @@ export default class Registration extends React.Component<IProps, IState> {
inhibit_login: undefined,
};
if (auth) registerParams.auth = auth;
Expand All @@ -60,7 +70,7 @@ index dd9be19..4226280 100644
debuglog("Registration: sending registration request:", auth);
return this.state.matrixClient.registerRequest(registerParams);
};
@@ -515,7 +536,7 @@ export default class Registration extends React.Component<IProps, IState> {
@@ -515,7 +539,7 @@ export default class Registration extends React.Component<IProps, IState> {
sessionId={this.props.sessionId}
clientSecret={this.props.clientSecret}
emailSid={this.props.idSid}
Expand All @@ -69,7 +79,7 @@ index dd9be19..4226280 100644
/>
);
} else if (!this.state.matrixClient && !this.state.busy) {
@@ -711,6 +732,12 @@ export default class Registration extends React.Component<IProps, IState> {
@@ -711,6 +735,12 @@ export default class Registration extends React.Component<IProps, IState> {
{errorText}
{serverDeadSection}
</AuthHeaderDisplay>
Expand Down
6 changes: 6 additions & 0 deletions res/themes/tchap-common/css/_tchap_custom.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
div.mx_SettingsTab.mx_SecurityUserSettingsTab > div:nth-child(4) > div:nth-child(2) {
display: none;
}

/* change link color and decoration in login error when email is not autorized */
.mx_Login_error.mx_Login_error_link{
color: $alert important!;
text-decoration: underline important!;
}
4 changes: 4 additions & 0 deletions src/i18n/strings/tchap_translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@
"fr": "Clés Tchap :",
"en": "Tchap keys:"
},
"That email is not allowed on Tchap" : {
"fr": "Votre adresse mail n'est pas autorisée sur Tchap. Demandez l'accès à Tchap pour votre administration via <a>ce formulaire</a>",
"en": "Your email adress is not allowed on Tchap. Make an autorization request <a>here</a>"
},
"Generate a new code": {
"fr": "Générer un nouveau code",
"en": "Generate a new code"
Expand Down
8 changes: 8 additions & 0 deletions src/util/TchapUrls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


export default class TchapUrls {

//url to request the opening of a new domain on Tchap
public static requestDomainUrl = "https://www.demarches-simplifiees.fr/commencer/utiliser-tchap";

}