Skip to content

Commit

Permalink
feat(sso): add feature flag to active sso flow
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Sep 30, 2024
1 parent 4d32167 commit 7d3952d
Show file tree
Hide file tree
Showing 15 changed files with 441 additions and 61 deletions.
3 changes: 3 additions & 0 deletions config.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
],
"feature_screenshare_call": ["*"]
},
"tchap_sso_flow": {
"isActive": false
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json",
"element_call": {
"url": "https://element-call.tchap.incubateur.net/"
Expand Down
6 changes: 5 additions & 1 deletion config.preprod.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@
"feature_space": ["*"],
"feature_audio_call": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
"feature_video_call": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
"feature_screenshare_call": ["*"]
"feature_screenshare_call": ["*"],
"feature_sso_flow": []
},
"tchap_sso_flow": {
"isActive": false
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
6 changes: 5 additions & 1 deletion config.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@
"feature_space": ["*"],
"feature_audio_call": ["*"],
"feature_video_call": ["agent.dinum.tchap.gouv.fr"],
"feature_screenshare_call": ["*"]
"feature_screenshare_call": ["*"],
"feature_sso_flow": []
},
"tchap_sso_flow": {
"isActive": false
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
3 changes: 3 additions & 0 deletions config.prod.lab.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,8 @@
"feature_video_call": ["agent.dinum.tchap.gouv.fr", "education.tchap.gouv.fr"],
"feature_screenshare_call": ["*"]
},
"tchap_sso_flow": {
"isActive": false
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ import { Features } from "../../../settings/Settings";
import { startOidcLogin } from "../../../utils/oidc/authorize";

import TchapUtils from '../../../../../../src/tchap/util/TchapUtils'; // :TCHAP: registration-for-mainlining
import TchapUrls from "../../../../../../src/tchap/util/TchapUrls";
import TchapUIFeature from "../../../../../../src/tchap/util/TchapUIFeature"; // :TCHAP: sso-agentconnect-flow
import ProconnectButton from "../../../../../../src/tchap/components/views/sso/ProconnectButton"; // :TCHAP: sso-agentconnect-flow

const debuglog = (...args: any[]): void => {
if (SettingsStore.getValue("debug_registration")) {
Expand Down Expand Up @@ -592,45 +593,51 @@ export default class Registration extends React.Component<IProps, IState> {
);
} else if (this.state.matrixClient && this.state.flows.length) {
let ssoSection: JSX.Element | undefined;
if (this.state.ssoFlow) {
let continueWithSection;
const providers = this.state.ssoFlow.identity_providers || [];
// when there is only a single (or 0) providers we show a wide button with `Continue with X` text
if (providers.length > 1) {
// i18n: ssoButtons is a placeholder to help translators understand context
continueWithSection = (
<h2 className="mx_AuthBody_centered">
{_t("auth|continue_with_sso", { ssoButtons: "" }).trim()}
</h2>
);
}

// i18n: ssoButtons & usernamePassword are placeholders to help translators understand context
ssoSection = (
<React.Fragment>
{continueWithSection}
<SSOButtons
matrixClient={this.loginLogic.createTemporaryClient()}
flow={this.state.ssoFlow}
loginType={this.state.ssoFlow.type === "m.login.sso" ? "sso" : "cas"}
fragmentAfterLogin={this.props.fragmentAfterLogin}
action={SSOAction.REGISTER}
/>
<h2 className="mx_AuthBody_centered">
{_t("auth|sso_or_username_password", {
ssoButtons: "",
usernamePassword: "",
}).trim()}
</h2>
</React.Fragment>
);
// :TCHAP: sso-agentconnect-flow
// if (this.state.ssoFlow) {
// let continueWithSection;
// const providers = this.state.ssoFlow.identity_providers || [];
// // when there is only a single (or 0) providers we show a wide button with `Continue with X` text
// if (providers.length > 1) {
// // i18n: ssoButtons is a placeholder to help translators understand context
// continueWithSection = (
// <h2 className="mx_AuthBody_centered">
// {_t("auth|continue_with_sso", { ssoButtons: "" }).trim()}
// </h2>
// );
// }

// // i18n: ssoButtons & usernamePassword are placeholders to help translators understand context
// ssoSection = (
// <React.Fragment>
// {continueWithSection}
// <SSOButtons
// matrixClient={this.loginLogic.createTemporaryClient()}
// flow={this.state.ssoFlow}
// loginType={this.state.ssoFlow.type === "m.login.sso" ? "sso" : "cas"}
// fragmentAfterLogin={this.props.fragmentAfterLogin}
// action={SSOAction.REGISTER}
// />
// <h2 className="mx_AuthBody_centered">
// {_t("auth|sso_or_username_password", {
// ssoButtons: "",
// usernamePassword: "",
// }).trim()}
// </h2>
// </React.Fragment>
// );
if (this.state.ssoFlow && TchapUIFeature.isSSOFlowActive()) {
ssoSection = <>
<ProconnectButton/>
<p style={{textAlign: "center", fontWeight: "bold"}}>{_t("auth|sso|or")}</p>
</>
}
// }
// end :TCHAP:

return (
<React.Fragment>
{/* :TCHAP: sso-agentconnect-flow */}
{/* {ssoSection} */}
{/* end :TCHAP: */}
{ssoSection}
<RegistrationForm
defaultUsername={this.state.formVals.username}
defaultEmail={this.state.formVals.email}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { UIFeature } from "../../../settings/UIFeature";
import LanguageSelector from "./LanguageSelector";
import EmbeddedPage from "../../structures/EmbeddedPage";
import { MATRIX_LOGO_HTML } from "../../structures/static-page-vars";
import TchapUIFeature from "../../../../../../src/tchap/util/TchapUIFeature";

interface IProps {}

Expand All @@ -47,7 +48,8 @@ export default class Welcome extends React.PureComponent<IProps> {
const brandingConfig = SdkConfig.getObject("branding");
const logoUrl = brandingConfig?.get("auth_header_logo_url") ?? "themes/element/img/logos/element-logo.svg";
replaceMap["$logoUrl"] = logoUrl;
pageUrl = "welcome.html";
// :TCHAP: sso-agentconnect-flow - pageUrl = "welcome.html";
pageUrl = TchapUIFeature.isSSOFlowActive() ? "welcome_sso.html" : "welcome.html";
}

return (
Expand Down
4 changes: 4 additions & 0 deletions modules/tchap-translations/tchap_translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -869,5 +869,9 @@
"auth|sso|error_email": {
"en": "You need to enter your professional email",
"fr": "Vous devez entrer votre adresse professionelle"
},
"auth|sso|or": {
"en": "or",
"fr": "ou"
}
}
14 changes: 11 additions & 3 deletions res/css/views/sso/TchapSSO.pcss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
form {
.tc_pronnect {
.tc_ButtonParent {
display: -webkit-box;
display: -webkit-flex;
Expand All @@ -24,13 +24,11 @@ form {
background-position: 30px center;
text-decoration: none;
color: #2e2f32 !important;
width: 100%;
}

.tc_ButtonProconnect {
background-color: #000091;
color: white !important;
margin-bottom: 40px;
}

.tc_Button_iconPC {
Expand All @@ -41,4 +39,14 @@ form {
display: flex;
justify-content: center;
}

.tc_login {
.tc_ButtonParent {
width: 100%;
}

.tc_ButtonProconnect {
margin-bottom: 40px;
}
}
}
24 changes: 7 additions & 17 deletions res/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,30 +292,20 @@ <h1 class="mx_Header_title">_t("Welcome to Tchap")<br />
</a>
</div>
<div class="mx_ButtonGroup">
<!-- :TCHAP: sso-agentconnect-flow -->
<!-- <div class="mx_ButtonRow">
<div class="mx_ButtonRow mx_Center_content">
<a href="https://tchap.beta.gouv.fr?mtm_campaign=TchapWebConnectLogo"
class="mx_ButtonParent mx_SecondaryButton ">
<div>_t("action|learn_more")</div>
</a>
</div>
<div class="mx_ButtonRow">
<a href="#/login" class="mx_ButtonParent mx_ButtonSignIn mx_Button_iconSignIn">
<div class="mx_ButtonLabel">_t("action|sign_in")</div>
</a>
<a href="#/register" class="mx_ButtonParent mx_ButtonCreateAccount mx_Button_iconCreateAccount">
<div class="mx_ButtonLabel">_t("action|create_account")</div>
</a>
</div> -->
<div class="tc_ButtonCol">
<a href="#/email-precheck-sso" class="tc_ButtonParent tc_ButtonProconnect tc_Button_iconPC">
<div class="mx_ButtonLabel">_t("auth|sso|email_title")</div>
</a>
<a href="https://www.proconnect.gouv.fr/" class="tc_ButtonProconnect_explanation ">
<div>_t("welcome|sso|proconnect_explanation")</div>
</a>
<a href="#/login" class="tc_ButtonParent tc_Button tc_ButtonBorder">
<div>_t("auth|sso|sign_in_password_instead")</div>
</a>
<a href="#/register" class="tc_Button">
<div>_t("action|create_account")</div>
</a>
</div>
<!-- end :TCHAP: -->
<div class="mx_ButtonRow mx_WelcomePage_guestFunctions">
<div>
<a href="#/directory" class="mx_ButtonParent mx_SecondaryButton mx_Button_iconRoomDirectory">
Expand Down
Loading

0 comments on commit 7d3952d

Please sign in to comment.