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
1 change: 1 addition & 0 deletions res/css/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
@import "./views/dialogs/_MessageEditHistoryDialog.scss";
@import "./views/dialogs/_ModalWidgetDialog.scss";
@import "./views/dialogs/_NewSessionReviewDialog.scss";
@import "./views/dialogs/_RegistrationEmailPromptDialog.scss";
@import "./views/dialogs/_RoomSettingsDialog.scss";
@import "./views/dialogs/_RoomSettingsDialogBridges.scss";
@import "./views/dialogs/_RoomUpgradeDialog.scss";
Expand Down
28 changes: 28 additions & 0 deletions res/css/views/dialogs/_RegistrationEmailPromptDialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_RegistrationEmailPromptDialog {
width: 417px;
jryans marked this conversation as resolved.
Show resolved Hide resolved

.mx_Dialog_content {
margin-bottom: 24px;
color: $tertiary-fg-color;
}

.mx_Dialog_primary {
width: 100%;
}
}
54 changes: 27 additions & 27 deletions src/components/views/auth/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import withValidation from '../elements/Validation';
import {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";
import PassphraseField from "./PassphraseField";
import CountlyAnalytics from "../../../CountlyAnalytics";
import Field from '../elements/Field';
import RegistrationEmailPromptDialog from '../dialogs/RegistrationEmailPromptDialog';
import QuestionDialog from '../dialogs/QuestionDialog';

enum RegistrationField {
Email = "field_email",
Expand Down Expand Up @@ -104,6 +107,7 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState

private onSubmit = async ev => {
ev.preventDefault();
ev.persist();

if (!this.props.canSubmit) return;

Expand All @@ -116,36 +120,36 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
if (this.state.email === '') {
const haveIs = Boolean(this.props.serverConfig.isUrl);

let desc;
if (this.props.serverRequiresIdServer && !haveIs) {
desc = _t(
"No identity server is configured so you cannot add an email address in order to " +
"reset your password in the future.",
);
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()) {
desc = _t(
"If you don't specify an email address, you won't be able to reset your password. " +
"Are you sure?",
);
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) => {
if (confirmed) {
this.setState({
email,
}, () => {
this.doSubmit(ev);
});
}
},
});
} else {
// user can't set an e-mail so don't prompt them to
this.doSubmit(ev);
return;
}

CountlyAnalytics.instance.track("onboarding_registration_submit_warn");

const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createTrackedDialog('If you don\'t specify an email address...', '', QuestionDialog, {
title: _t("Warning!"),
description: desc,
button: _t("Continue"),
onFinished: (confirmed) => {
if (confirmed) {
this.doSubmit(ev);
}
},
});
} else {
this.doSubmit(ev);
}
Expand Down Expand Up @@ -443,7 +447,6 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
if (!this.showEmail()) {
return null;
}
const Field = sdk.getComponent('elements.Field');
const emailPlaceholder = this.authStepIsRequired('m.login.email.identity') ?
_t("Email") :
_t("Email (optional)");
Expand Down Expand Up @@ -473,7 +476,6 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
}

renderPasswordConfirm() {
const Field = sdk.getComponent('elements.Field');
return <Field
id="mx_RegistrationForm_passwordConfirm"
ref={field => this[RegistrationField.PasswordConfirm] = field}
Expand All @@ -493,7 +495,6 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
return null;
}
const CountryDropdown = sdk.getComponent('views.auth.CountryDropdown');
const Field = sdk.getComponent('elements.Field');
const phoneLabel = this.authStepIsRequired('m.login.msisdn') ?
_t("Phone") :
_t("Phone (optional)");
Expand All @@ -515,7 +516,6 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
}

renderUsername() {
const Field = sdk.getComponent('elements.Field');
return <Field
id="mx_RegistrationForm_username"
ref={field => this[RegistrationField.Username] = field}
Expand Down
96 changes: 96 additions & 0 deletions src/components/views/dialogs/RegistrationEmailPromptDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import * as React from "react";

import { _t } from '../../../languageHandler';
import { IDialogProps } from "./IDialogProps";
import {useRef, useState} from "react";
import Field from "../elements/Field";
import CountlyAnalytics from "../../../CountlyAnalytics";
import withValidation from "../elements/Validation";
import * as Email from "../../../email";
import BaseDialog from "./BaseDialog";
import DialogButtons from "../elements/DialogButtons";

interface IProps extends IDialogProps {
onFinished(continued: boolean, email?: string): void;
}

const validation = withValidation({
rules: [
{
key: "email",
test: ({ value }) => !value || Email.looksValid(value),
invalid: () => _t("Doesn't look like a valid email address"),
},
],
});

const RegistrationEmailPromptDialog: React.FC<IProps> = ({onFinished}) => {
const [email, setEmail] = useState("");
const fieldRef = useRef<Field>();

const onSubmit = async () => {
if (email) {
const valid = await fieldRef.current.validate({ allowEmpty: false });

if (!valid) {
fieldRef.current.focus();
fieldRef.current.validate({ allowEmpty: false, focused: true });
return;
}
}

onFinished(true, email);
};

return <BaseDialog
title={_t("Continuing without email")}
className="mx_RegistrationEmailPromptDialog"
contentId="mx_RegistrationEmailPromptDialog"
onFinished={() => onFinished(false)}
fixedWidth={false}
>
<div className="mx_Dialog_content" id="mx_RegistrationEmailPromptDialog">
<p>{_t("Just a heads up, if you don't add an email and forget your password, you could " +
"<b>permanently lose access to your account.</b>", {}, {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
b: sub => <b>{sub}</b>,
})}</p>
<form onSubmit={onSubmit}>
<Field
ref={fieldRef}
type="text"
label={_t("Email (optional)")}
value={email}
onChange={ev => {
setEmail(ev.target.value);
}}
onValidate={async fieldState => await validation(fieldState)}
onFocus={() => CountlyAnalytics.instance.track("onboarding_registration_email2_focus")}
jryans marked this conversation as resolved.
Show resolved Hide resolved
onBlur={() => CountlyAnalytics.instance.track("onboarding_registration_email2_blur")}
/>
</form>
</div>
<DialogButtons
primaryButton={_t("Continue")}
onPrimaryButtonClick={onSubmit}
hasCancel={false}
/>
</BaseDialog>;
};

export default RegistrationEmailPromptDialog;
4 changes: 3 additions & 1 deletion src/components/views/elements/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default class Field extends React.PureComponent<PropShapes, IState> {
}
};

private async validate({ focused, allowEmpty = true }: {focused: boolean, allowEmpty?: boolean}) {
public async validate({ focused, allowEmpty = true }: {focused?: boolean, allowEmpty?: boolean}) {
if (!this.props.onValidate) {
return;
}
Expand Down Expand Up @@ -196,6 +196,8 @@ export default class Field extends React.PureComponent<PropShapes, IState> {
feedbackVisible: false,
});
}

return valid;
}

public render() {
Expand Down
7 changes: 4 additions & 3 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,10 @@
"Use this session to verify your new one, granting it access to encrypted messages:": "Use this session to verify your new one, granting it access to encrypted messages:",
"If you didn’t sign in to this session, your account may be compromised.": "If you didn’t sign in to this session, your account may be compromised.",
"This wasn't me": "This wasn't me",
"Doesn't look like a valid email address": "Doesn't look like a valid email address",
"Continuing without email": "Continuing without email",
"Just a heads up, if you don't add an email and forget your password, you could <b>permanently lose access to your account.</b>": "Just a heads up, if you don't add an email and forget your password, you could <b>permanently lose access to your account.</b>",
"Email (optional)": "Email (optional)",
"Please fill why you're reporting.": "Please fill why you're reporting.",
"Report Content to Your Homeserver Administrator": "Report Content to Your Homeserver Administrator",
"Reporting this message will send its unique 'event ID' to the administrator of your homeserver. If messages in this room are encrypted, your homeserver administrator will not be able to read the message text or view any files or images.": "Reporting this message will send its unique 'event ID' to the administrator of your homeserver. If messages in this room are encrypted, your homeserver administrator will not be able to read the message text or view any files or images.",
Expand Down Expand Up @@ -2226,7 +2230,6 @@
"Keep going...": "Keep going...",
"Enter username": "Enter username",
"Enter email address": "Enter email address",
"Doesn't look like a valid email address": "Doesn't look like a valid email address",
"Enter phone number": "Enter phone number",
"Doesn't look like a valid phone number": "Doesn't look like a valid phone number",
"Email": "Email",
Expand All @@ -2236,14 +2239,12 @@
"Sign in with": "Sign in with",
"Sign in": "Sign in",
"No identity server is configured so you cannot add an email address in order to reset your password in the future.": "No identity server is configured so you cannot add an email address in order to reset your password in the future.",
"If you don't specify an email address, you won't be able to reset your password. Are you sure?": "If you don't specify an email address, you won't be able to reset your password. Are you sure?",
"Use an email address to recover your account": "Use an email address to recover your account",
"Enter email address (required on this homeserver)": "Enter email address (required on this homeserver)",
"Passwords don't match": "Passwords don't match",
"Other users can invite you to rooms using your contact details": "Other users can invite you to rooms using your contact details",
"Enter phone number (required on this homeserver)": "Enter phone number (required on this homeserver)",
"Use lowercase letters, numbers, dashes and underscores only": "Use lowercase letters, numbers, dashes and underscores only",
"Email (optional)": "Email (optional)",
"Phone (optional)": "Phone (optional)",
"Register": "Register",
"Set an email for account recovery. Use email or phone to optionally be discoverable by existing contacts.": "Set an email for account recovery. Use email or phone to optionally be discoverable by existing contacts.",
Expand Down