Improve SSO UIA
Fixes Fallback UIA postmessage interface Auto-closes SSO UIA tab when the user has completed the flow within it Error for when auth stage is restarted because it failed
This commit is contained in:
parent
34ae766893
commit
1761a4ec80
4 changed files with 62 additions and 9 deletions
|
@ -177,7 +177,13 @@ export default class InteractiveAuthComponent extends React.Component {
|
||||||
stageState: stageState,
|
stageState: stageState,
|
||||||
errorText: stageState.error,
|
errorText: stageState.error,
|
||||||
}, () => {
|
}, () => {
|
||||||
if (oldStage != stageType) this._setFocus();
|
if (oldStage !== stageType) {
|
||||||
|
this._setFocus();
|
||||||
|
} else if (!stageState.error && this._stageComponent.current &&
|
||||||
|
this._stageComponent.current.attemptFailed
|
||||||
|
) {
|
||||||
|
this._stageComponent.current.attemptFailed();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -325,9 +325,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.props.realQueryParams,
|
this.props.realQueryParams,
|
||||||
this.props.defaultDeviceDisplayName,
|
this.props.defaultDeviceDisplayName,
|
||||||
).then(async (loggedIn) => {
|
).then(async (loggedIn) => {
|
||||||
|
if (this.props.realQueryParams?.loginToken) {
|
||||||
|
// remove the loginToken from the URL regardless
|
||||||
|
this.props.onTokenLoginCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
this.tokenLogin = true;
|
this.tokenLogin = true;
|
||||||
this.props.onTokenLoginCompleted();
|
|
||||||
|
|
||||||
// Create and start the client
|
// Create and start the client
|
||||||
await Lifecycle.restoreFromLocalStorage({
|
await Lifecycle.restoreFromLocalStorage({
|
||||||
|
|
|
@ -609,8 +609,12 @@ export class SSOAuthEntry extends React.Component {
|
||||||
this.props.authSessionId,
|
this.props.authSessionId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._popupWindow = null;
|
||||||
|
window.addEventListener("message", this._onReceiveMessage);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
phase: SSOAuthEntry.PHASE_PREAUTH,
|
phase: SSOAuthEntry.PHASE_PREAUTH,
|
||||||
|
attemptFailed: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,12 +622,33 @@ export class SSOAuthEntry extends React.Component {
|
||||||
this.props.onPhaseChange(SSOAuthEntry.PHASE_PREAUTH);
|
this.props.onPhaseChange(SSOAuthEntry.PHASE_PREAUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
window.removeEventListener("message", this._onReceiveMessage);
|
||||||
|
if (this._popupWindow) {
|
||||||
|
this._popupWindow.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attemptFailed = () => {
|
||||||
|
this.setState({
|
||||||
|
attemptFailed: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
_onReceiveMessage = event => {
|
||||||
|
if (event.data === "authDone" && event.origin === this.props.matrixClient.getHomeserverUrl()) {
|
||||||
|
if (this._popupWindow) {
|
||||||
|
this._popupWindow.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onStartAuthClick = () => {
|
onStartAuthClick = () => {
|
||||||
// Note: We don't use PlatformPeg's startSsoAuth functions because we almost
|
// Note: We don't use PlatformPeg's startSsoAuth functions because we almost
|
||||||
// certainly will need to open the thing in a new tab to avoid losing application
|
// certainly will need to open the thing in a new tab to avoid losing application
|
||||||
// context.
|
// context.
|
||||||
|
|
||||||
window.open(this._ssoUrl, '_blank');
|
this._popupWindow = window.open(this._ssoUrl, "_blank");
|
||||||
this.setState({phase: SSOAuthEntry.PHASE_POSTAUTH});
|
this.setState({phase: SSOAuthEntry.PHASE_POSTAUTH});
|
||||||
this.props.onPhaseChange(SSOAuthEntry.PHASE_POSTAUTH);
|
this.props.onPhaseChange(SSOAuthEntry.PHASE_POSTAUTH);
|
||||||
};
|
};
|
||||||
|
@ -656,10 +681,28 @@ export class SSOAuthEntry extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div className='mx_InteractiveAuthEntryComponents_sso_buttons'>
|
let errorSection;
|
||||||
{cancelButton}
|
if (this.props.errorText) {
|
||||||
{continueButton}
|
errorSection = (
|
||||||
</div>;
|
<div className="error" role="alert">
|
||||||
|
{ this.props.errorText }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (this.state.attemptFailed) {
|
||||||
|
errorSection = (
|
||||||
|
<div className="error" role="alert">
|
||||||
|
{ _t("Something went wrong in confirming your identity. Cancel and try again.") }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <React.Fragment>
|
||||||
|
{ errorSection }
|
||||||
|
<div className="mx_InteractiveAuthEntryComponents_sso_buttons">
|
||||||
|
{cancelButton}
|
||||||
|
{continueButton}
|
||||||
|
</div>
|
||||||
|
</React.Fragment>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,8 +753,7 @@ export class FallbackAuthEntry extends React.Component {
|
||||||
this.props.loginType,
|
this.props.loginType,
|
||||||
this.props.authSessionId,
|
this.props.authSessionId,
|
||||||
);
|
);
|
||||||
this._popupWindow = window.open(url);
|
this._popupWindow = window.open(url, "_blank");
|
||||||
this._popupWindow.opener = null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_onReceiveMessage = event => {
|
_onReceiveMessage = event => {
|
||||||
|
|
|
@ -2334,6 +2334,7 @@
|
||||||
"Please enter the code it contains:": "Please enter the code it contains:",
|
"Please enter the code it contains:": "Please enter the code it contains:",
|
||||||
"Code": "Code",
|
"Code": "Code",
|
||||||
"Submit": "Submit",
|
"Submit": "Submit",
|
||||||
|
"Something went wrong in confirming your identity. Cancel and try again.": "Something went wrong in confirming your identity. Cancel and try again.",
|
||||||
"Start authentication": "Start authentication",
|
"Start authentication": "Start authentication",
|
||||||
"Enter password": "Enter password",
|
"Enter password": "Enter password",
|
||||||
"Nice, strong password!": "Nice, strong password!",
|
"Nice, strong password!": "Nice, strong password!",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue