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

Social Login and login delight tweaks #5426

Merged
merged 24 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc3542a
Extend Platform to support idpId for SSO flows
t3chguy Nov 19, 2020
a1351ea
Increase Dialog button mixin border-radius to 8px
t3chguy Nov 20, 2020
6f6e850
lowercase username placeholder in Password Login and Registration Form
t3chguy Nov 23, 2020
2263280
Improve no email warning during registration
t3chguy Nov 23, 2020
613710b
Iterate Auth copy
t3chguy Nov 23, 2020
1d53a5c
Initial support for MSC2858
t3chguy Nov 23, 2020
b1ca1eb
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Nov 24, 2020
f7d7182
Iterate Multi-SSO support
t3chguy Nov 24, 2020
2f64160
Remove backwards compatibility in ServerConfig for m.require_identity…
t3chguy Nov 24, 2020
225d541
Extend Field and InfoDialog with more configurability
t3chguy Nov 25, 2020
6a315e8
Improve auth error messages
t3chguy Nov 25, 2020
758b47c
Replace *ServerConfig and SignInToText with ServerPicker
t3chguy Nov 25, 2020
1b1c482
Iterate tests
t3chguy Nov 25, 2020
c408419
delint
t3chguy Nov 25, 2020
3bdedd7
fix another test
t3chguy Nov 25, 2020
8602545
Remove unused dialog, todo comments and other tiny tweaks
t3chguy Nov 26, 2020
5f03cbd
Iterate PR some more
t3chguy Nov 26, 2020
26e1cdb
Update i18n
t3chguy Dec 1, 2020
ba542f2
Merge branch 'develop' into t3chguy/socials
t3chguy Dec 1, 2020
eb25c39
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Dec 1, 2020
e0b6844
i18n
t3chguy Dec 1, 2020
d8e46c7
Merge remote-tracking branch 'origin/t3chguy/socials' into t3chguy/so…
t3chguy Dec 1, 2020
3fda7e3
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Dec 2, 2020
8593845
i18n
t3chguy Dec 2, 2020
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
10 changes: 0 additions & 10 deletions res/css/views/auth/_ServerConfig.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,3 @@ limitations under the License.
display: block;
color: $warning-color;
}

.mx_ServerConfig_identityServer {
transform: scaleY(0);
transform-origin: top;
transition: transform 0.25s;

&.mx_ServerConfig_identityServer_shown {
transform: scaleY(1);
}
}
7 changes: 0 additions & 7 deletions src/PasswordReset.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export default class PasswordReset {
this.identityServerDomain = identityUrl ? identityUrl.split("://")[1] : null;
}

doesServerRequireIdServerParam() {
return this.client.doesServerRequireIdServerParam();
}

/**
* Attempt to reset the user's password. This will trigger a side-effect of
* sending an email to the provided email address.
Expand Down Expand Up @@ -78,9 +74,6 @@ export default class PasswordReset {
sid: this.sessionId,
client_secret: this.clientSecret,
};
if (await this.doesServerRequireIdServerParam()) {
creds.id_server = this.identityServerDomain;
}

try {
await this.client.setPassword({
Expand Down
22 changes: 0 additions & 22 deletions src/components/structures/auth/ForgotPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default class ForgotPassword extends React.Component {
serverIsAlive: true,
serverErrorIsFatal: false,
serverDeadError: "",
serverRequiresIdServer: null,
};

constructor(props) {
Expand Down Expand Up @@ -93,12 +92,8 @@ export default class ForgotPassword extends React.Component {
serverConfig.isUrl,
);

const pwReset = new PasswordReset(serverConfig.hsUrl, serverConfig.isUrl);
const serverRequiresIdServer = await pwReset.doesServerRequireIdServerParam();

this.setState({
serverIsAlive: true,
serverRequiresIdServer,
});
} catch (e) {
this.setState(AutoDiscoveryUtils.authComponentStateForError(e, "forgot_password"));
Expand Down Expand Up @@ -216,7 +211,6 @@ export default class ForgotPassword extends React.Component {
serverConfig={this.props.serverConfig}
onServerConfigChange={this.props.onServerConfigChange}
delayTimeMs={0}
showIdentityServerIfRequiredByHomeserver={true}
onAfterSubmit={this.onServerDetailsNextPhaseClick}
submitText={_t("Next")}
submitClass="mx_Login_submit"
Expand Down Expand Up @@ -274,22 +268,6 @@ export default class ForgotPassword extends React.Component {
</a>;
}

if (!this.props.serverConfig.isUrl && this.state.serverRequiresIdServer) {
return <div>
<h3>
{yourMatrixAccountText}
{editLink}
</h3>
{_t(
"No identity server is configured: " +
"add one in server settings to reset your password.",
)}
<a className="mx_AuthBody_changeFlow" onClick={this.onLoginClick} href="#">
{_t('Sign in instead')}
</a>
</div>;
}

return <div>
{errorText}
{serverDeadSection}
Expand Down
12 changes: 0 additions & 12 deletions src/components/structures/auth/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ interface IState {
// Our matrix client - part of state because we can't render the UI auth
// component without it.
matrixClient?: MatrixClient;
// whether the HS requires an ID server to register with a threepid
serverRequiresIdServer?: boolean;
// The user ID we've just registered
registeredUsername?: string;
// if a different user ID to the one we just registered is logged in,
Expand Down Expand Up @@ -254,13 +252,6 @@ export default class Registration extends React.Component<IProps, IState> {
idBaseUrl: isUrl,
});

let serverRequiresIdServer = true;
try {
serverRequiresIdServer = await cli.doesServerRequireIdServerParam();
} catch (e) {
console.log("Unable to determine is server needs id_server param", e);
}

this.loginLogic.setHomeserverUrl(hsUrl);
this.loginLogic.setIdentityServerUrl(isUrl);

Expand All @@ -274,7 +265,6 @@ export default class Registration extends React.Component<IProps, IState> {

this.setState({
matrixClient: cli,
serverRequiresIdServer,
ssoFlow,
busy: false,
});
Expand Down Expand Up @@ -573,7 +563,6 @@ export default class Registration extends React.Component<IProps, IState> {
serverConfig={this.props.serverConfig}
onServerConfigChange={this.props.onServerConfigChange}
delayTimeMs={250}
showIdentityServerIfRequiredByHomeserver={true}
onAfterSubmit={this.onServerDetailsNextPhaseClick}
submitText={_t("Next")}
submitClass="mx_Login_submit"
Expand Down Expand Up @@ -644,7 +633,6 @@ export default class Registration extends React.Component<IProps, IState> {
flows={this.state.flows}
serverConfig={this.props.serverConfig}
canSubmit={!this.state.serverErrorIsFatal}
serverRequiresIdServer={this.state.serverRequiresIdServer}
/>
</React.Fragment>;
}
Expand Down
13 changes: 0 additions & 13 deletions src/components/views/auth/InteractiveAuthEntryComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.

import React, {createRef} from 'react';
import PropTypes from 'prop-types';
import url from 'url';
import classnames from 'classnames';

import * as sdk from '../../../index';
Expand Down Expand Up @@ -500,17 +499,11 @@ export class MsisdnAuthEntry extends React.Component {
});

try {
const requiresIdServerParam =
await this.props.matrixClient.doesServerRequireIdServerParam();
let result;
if (this._submitUrl) {
result = await this.props.matrixClient.submitMsisdnTokenOtherUrl(
this._submitUrl, this._sid, this.props.clientSecret, this.state.token,
);
} else if (requiresIdServerParam) {
result = await this.props.matrixClient.submitMsisdnToken(
this._sid, this.props.clientSecret, this.state.token,
);
} else {
throw new Error("The registration with MSISDN flow is misconfigured");
}
Expand All @@ -519,12 +512,6 @@ export class MsisdnAuthEntry extends React.Component {
sid: this._sid,
client_secret: this.props.clientSecret,
};
if (requiresIdServerParam) {
const idServerParsedUrl = url.parse(
this.props.matrixClient.getIdentityServerUrl(),
);
creds.id_server = idServerParsedUrl.host;
}
this.props.submitAuthDict({
type: MsisdnAuthEntry.LOGIN_TYPE,
// TODO: Remove `threepid_creds` once servers support proper UIA
Expand Down
41 changes: 3 additions & 38 deletions src/components/views/auth/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ interface IProps {
}[];
serverConfig: ValidatedServerConfig;
canSubmit?: boolean;
serverRequiresIdServer?: boolean;

onRegisterClick(params: {
username: string;
Expand Down Expand Up @@ -118,21 +117,7 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
}

if (this.state.email === '') {
const haveIs = Boolean(this.props.serverConfig.isUrl);

if (this.props.serverRequiresIdServer && !haveIs) {
Modal.createTrackedDialog("No identity server no email", '', QuestionDialog, {
title: _t("Warning!"),
description: _t(
"No identity server is configured so you cannot add an email address in order to " +
"reset your password in the future.",
),
button: _t("Continue"),
onFinished: async (confirmed) => {
if (confirmed) this.doSubmit(ev);
},
});
} else if (this.showEmail()) {
if (this.showEmail()) {
CountlyAnalytics.instance.track("onboarding_registration_submit_warn");
jryans marked this conversation as resolved.
Show resolved Hide resolved
Modal.createTrackedDialog("Email prompt dialog", '', RegistrationEmailPromptDialog, {
onFinished: async (confirmed: boolean, email?: string) => {
Expand Down Expand Up @@ -420,24 +405,15 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
}

private showEmail() {
const haveIs = Boolean(this.props.serverConfig.isUrl);
if (
(this.props.serverRequiresIdServer && !haveIs) ||
!this.authStepIsUsed('m.login.email.identity')
) {
if (!this.authStepIsUsed('m.login.email.identity')) {
return false;
}
return true;
}

private showPhoneNumber() {
const threePidLogin = !SdkConfig.get().disable_3pid_login;
const haveIs = Boolean(this.props.serverConfig.isUrl);
if (
!threePidLogin ||
(this.props.serverRequiresIdServer && !haveIs) ||
!this.authStepIsUsed('m.login.msisdn')
) {
if (!threePidLogin || !this.authStepIsUsed('m.login.msisdn')) {
return false;
}
return true;
Expand Down Expand Up @@ -556,16 +532,6 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
</div>;
}
}
const haveIs = Boolean(this.props.serverConfig.isUrl);
let noIsText = null;
if (this.props.serverRequiresIdServer && !haveIs) {
noIsText = <div>
{_t(
"No identity server is configured so you cannot add an email address in order to " +
"reset your password in the future.",
)}
</div>;
}

return (
<div>
Expand All @@ -582,7 +548,6 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
{this.renderPhoneNumber()}
</div>
{ emailHelperText }
{ noIsText }
{ registerButton }
</form>
</div>
Expand Down
68 changes: 0 additions & 68 deletions src/components/views/auth/ServerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import { _t } from '../../../languageHandler';
import {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";
import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils";
import SdkConfig from "../../../SdkConfig";
import { createClient } from 'matrix-js-sdk/src/matrix';
import classNames from 'classnames';
import CountlyAnalytics from "../../../CountlyAnalytics";

/*
Expand All @@ -50,10 +48,6 @@ export default class ServerConfig extends React.PureComponent {
// Optional class for the submit button. Only applies if the submit button
// is to be rendered.
submitClass: PropTypes.string,

// Whether the flow this component is embedded in requires an identity
// server when the homeserver says it will need one. Default false.
showIdentityServerIfRequiredByHomeserver: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -69,7 +63,6 @@ export default class ServerConfig extends React.PureComponent {
errorText: "",
hsUrl: props.serverConfig.hsUrl,
isUrl: props.serverConfig.isUrl,
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
showIdentityServer: false,
};

CountlyAnalytics.instance.track("onboarding_custom_server");
Expand All @@ -92,23 +85,6 @@ export default class ServerConfig extends React.PureComponent {
return result;
}

// If the UI flow this component is embedded in requires an identity
// server when the homeserver says it will need one, check first and
// reveal this field if not already shown.
// XXX: This a backward compatibility path for homeservers that require
// an identity server to be passed during certain flows.
// See also https://github.com/matrix-org/synapse/pull/5868.
if (
this.props.showIdentityServerIfRequiredByHomeserver &&
!this.state.showIdentityServer &&
await this.isIdentityServerRequiredByHomeserver()
) {
this.setState({
showIdentityServer: true,
});
return null;
}

return result;
}

Expand Down Expand Up @@ -165,15 +141,6 @@ export default class ServerConfig extends React.PureComponent {
}
}

async isIdentityServerRequiredByHomeserver() {
// XXX: We shouldn't have to create a whole new MatrixClient just to
// check if the homeserver requires an identity server... Should it be
// extracted to a static utils function...?
return createClient({
baseUrl: this.state.hsUrl,
}).doesServerRequireIdServerParam();
}

onHomeserverBlur = (ev) => {
this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
this.validateServer();
Expand All @@ -185,17 +152,6 @@ export default class ServerConfig extends React.PureComponent {
this.setState({ hsUrl });
};

onIdentityServerBlur = (ev) => {
this._isTimeoutId = this._waitThenInvoke(this._isTimeoutId, () => {
this.validateServer();
});
};

onIdentityServerChange = (ev) => {
const isUrl = ev.target.value;
this.setState({ isUrl });
};

onSubmit = async (ev) => {
ev.preventDefault();
ev.stopPropagation();
Expand Down Expand Up @@ -239,29 +195,6 @@ export default class ServerConfig extends React.PureComponent {
</div>;
}

_renderIdentityServerSection() {
const Field = sdk.getComponent('elements.Field');
const classes = classNames({
"mx_ServerConfig_identityServer": true,
"mx_ServerConfig_identityServer_shown": this.state.showIdentityServer,
});
return <div className={classes}>
{_t("Enter your custom identity server URL <a>What does this mean?</a>", {}, {
a: sub => <a className="mx_ServerConfig_help" href="#" onClick={this.showHelpPopup}>
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
{sub}
</a>,
})}
<Field
label={_t("Identity Server URL")}
placeholder={this.props.serverConfig.isUrl}
value={this.state.isUrl || ''}
onBlur={this.onIdentityServerBlur}
onChange={this.onIdentityServerChange}
disabled={this.state.busy}
/>
</div>;
}

render() {
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');

Expand All @@ -283,7 +216,6 @@ export default class ServerConfig extends React.PureComponent {
<h3>{_t("Other servers")}</h3>
{errorText}
{this._renderHomeserverSection()}
{this._renderIdentityServerSection()}
{submitButton}
</form>
);
Expand Down