Skip to content

Commit

Permalink
feat(sso): add email domain precheck sso flow
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Sep 19, 2024
1 parent 84f37f3 commit f03c333
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions linked-dependencies/matrix-react-sdk/src/Views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ enum Views {

// Another instance of the application has started up. We just show an error page.
LOCK_STOLEN,

// :TCHAP: screen before launching sso
EMAIL_PRECHECK_SSO
}

export default Views;
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ import { checkSessionLockFree, getSessionLock } from "../../utils/SessionLock";
import { SessionLockStolenView } from "./auth/SessionLockStolenView";
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
import { LoginSplashView } from "./auth/LoginSplashView";
import TchapUrls from "../../../../../src/tchap/util/TchapUrls"; // :TCHAP: activate-cross-signing-and-secure-storage-react
import { cleanUpDraftsIfRequired } from "../../DraftCleaner";

import TchapUrls from "../../../../../src/tchap/util/TchapUrls"; // :TCHAP: activate-cross-signing-and-secure-storage-react
import EmailVerificationPage from "../../../../../src/tchap/components/views/sso/EmailVerificationPage"; // :TCHAP: sso-agentconnect-flow

// legacy export
export { default as Views } from "../../Views";

Expand Down Expand Up @@ -946,6 +948,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
true,
);
break;
// :TCHAP: sso-agentconnect-flow
case Action.EmailPrecheckSSO:
if (Lifecycle.isSoftLogout()) {
this.onSoftLogout();
break;
}
this.viewEmailPrecheckSSO();
break;
// end :TCHAP:
}
};

Expand Down Expand Up @@ -1104,6 +1115,17 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
this.themeWatcher.recheck();
}

// :TCHAP: sso-agentconnect-flow
private viewEmailPrecheckSSO() {
this.setStateForNewView({
view: Views.EMAIL_PRECHECK_SSO
});
this.notifyNewScreen("email-precheck-sso");
ThemeController.isLogin = true;
this.themeWatcher.recheck();
}
// end :TCHAP:

private viewHome(justRegistered = false): void {
// The home page requires the "logged in" view, so we'll set that.
this.setStateForNewView({
Expand Down Expand Up @@ -1875,6 +1897,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
userId: userId,
subAction: params?.action,
});
// :TCHAP: sso-agentconnect-flow
} else if (screen = "email-precheck-sso") {
dis.dispatch({
action: "email_precheck_sso",
params
});
// end :TCHAP:
} else {
logger.info(`Ignoring showScreen for '${screen}'`);
}
Expand Down Expand Up @@ -2137,6 +2166,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
view = <UseCaseSelection onFinished={(useCase): Promise<void> => this.onShowPostLoginScreen(useCase)} />;
} else if (this.state.view === Views.LOCK_STOLEN) {
view = <SessionLockStolenView />;
// :TCHAP: sso-agentconnect-flow
} else if (this.state.view === Views.EMAIL_PRECHECK_SSO) {
view = <EmailVerificationPage />;
// end :TCHAP:
} else {
logger.error(`Unknown view ${this.state.view}`);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,9 @@ export enum Action {
* Opens right panel room summary and focuses the search input
*/
FocusMessageSearch = "focus_search",

/**
* :TCHAP: Open new page to check email instance before launching SSO
*/
EmailPrecheckSSO = "email_precheck_sso"
}
3 changes: 3 additions & 0 deletions res/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ <h1 class="mx_Header_title">_t("Welcome to Tchap")<br />
</a>
</div>
<div class="mx_ButtonRow">
<a href="#/email-precheck-sso" class="mx_ButtonParent mx_ButtonSignIn mx_Button_iconSignIn">
<div class="mx_ButtonLabel">Pro Connect</div>
</a>
<a href="#/login" class="mx_ButtonParent mx_ButtonSignIn mx_Button_iconSignIn">
<div class="mx_ButtonLabel">_t("action|sign_in")</div>
</a>
Expand Down

0 comments on commit f03c333

Please sign in to comment.