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

Support registration tokens #7275

Merged
merged 24 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b10be8
Support token authenticated registration
govynnus Dec 3, 2021
39c258a
Backwards compatibility with unstable auth type
govynnus Feb 18, 2022
8d3e1d9
Make LOGIN_TYPE public and readonly
govynnus Apr 10, 2022
1ddf830
Update registration-tokens to latest develop
govynnus Apr 10, 2022
f9a3fe8
Remove line related to skinning
govynnus Apr 10, 2022
47e3a7a
Change empty string to null
govynnus Apr 10, 2022
3a30db6
Use "public"s for new code style
govynnus May 12, 2022
e76180e
Merge branch 'develop' into registration-tokens
govynnus May 16, 2022
939a5ec
Change input to AccessibleButton
govynnus May 16, 2022
6fa9204
Add more detail regarding source of token
govynnus May 16, 2022
8e911d6
Merge remote-tracking branch 'upstream/develop' into registration-tokens
govynnus Sep 10, 2022
f489cd5
Fix lint error
govynnus Aug 12, 2022
6cb3260
Change null back to ""
govynnus Sep 10, 2022
3ebb998
Disable submit button when no token entered
govynnus Sep 10, 2022
a19b417
Add test for registration tokens
govynnus Sep 10, 2022
73e0f8a
Merge remote-tracking branch 'upstream/develop' into registration-tokens
govynnus Sep 24, 2022
43a3e4e
Merge remote-tracking branch 'upstream/develop' into registration-tokens
govynnus Oct 19, 2022
1881fa5
Merge remote-tracking branch 'upstream/master' into registration-tokens
govynnus Jan 17, 2023
04911e1
Merge remote-tracking branch 'upstream/develop' into registration-tokens
govynnus Jan 17, 2023
aea870d
Fix linting errors
govynnus Jan 18, 2023
3636932
Fix test for registration tokens
govynnus Jan 18, 2023
a632da7
Merge remote-tracking branch 'upstream/develop' into registration-tokens
govynnus Jan 18, 2023
3a944c0
Merge branch 'develop' into registration-tokens
andybalaam Jan 24, 2023
284ba03
Add missing type
andybalaam Jan 24, 2023
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
91 changes: 91 additions & 0 deletions src/components/views/auth/InteractiveAuthEntryComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,94 @@ export class MsisdnAuthEntry extends React.Component<IMsisdnAuthEntryProps, IMsi
}
}

interface IRegistrationTokenAuthEntryState {
registrationToken: string;
}

@replaceableComponent("views.auth.RegistrationTokenAuthEntry")
govynnus marked this conversation as resolved.
Show resolved Hide resolved
export class RegistrationTokenAuthEntry extends React.Component<IAuthEntryProps, IRegistrationTokenAuthEntryState> {
static LOGIN_TYPE = AuthType.RegistrationToken;
govynnus marked this conversation as resolved.
Show resolved Hide resolved

constructor(props) {
govynnus marked this conversation as resolved.
Show resolved Hide resolved
super(props);

this.state = {
registrationToken: "",
govynnus marked this conversation as resolved.
Show resolved Hide resolved
};
}

componentDidMount() {
govynnus marked this conversation as resolved.
Show resolved Hide resolved
this.props.onPhaseChange(DEFAULT_PHASE);
}

private onSubmit = (e: FormEvent) => {
e.preventDefault();
if (this.props.busy) return;

this.props.submitAuthDict({
// Could be AuthType.RegistrationToken or AuthType.UnstableRegistrationToken
type: this.props.loginType,
token: this.state.registrationToken,
});
};

private onRegistrationTokenFieldChange = (ev: ChangeEvent<HTMLInputElement>) => {
// enable the submit button if the registration token is non-empty
this.setState({
registrationToken: ev.target.value,
});
};

render() {
govynnus marked this conversation as resolved.
Show resolved Hide resolved
const registrationTokenBoxClass = classNames({
"error": this.props.errorText,
});

let submitButtonOrSpinner;
if (this.props.busy) {
submitButtonOrSpinner = <Spinner />;
} else {
submitButtonOrSpinner = (
<input type="submit"
className="mx_Dialog_primary"
disabled={!this.state.registrationToken}
value={_t("Continue")}
/>
govynnus marked this conversation as resolved.
Show resolved Hide resolved
);
}

let errorSection;
if (this.props.errorText) {
errorSection = (
<div className="error" role="alert">
{ this.props.errorText }
</div>
);
}

return (
<div>
<p>{ _t("Enter a registration token.") }</p>
<form onSubmit={this.onSubmit} className="mx_InteractiveAuthEntryComponents_registrationTokenSection">
<Field
className={registrationTokenBoxClass}
type="text"
name="registrationTokenField"
label={_t("Registration token")}
autoFocus={true}
value={this.state.registrationToken}
onChange={this.onRegistrationTokenFieldChange}
/>
{ errorSection }
<div className="mx_button_row">
{ submitButtonOrSpinner }
</div>
</form>
</div>
);
}
}

interface ISSOAuthEntryProps extends IAuthEntryProps {
continueText?: string;
continueKind?: string;
Expand Down Expand Up @@ -854,6 +942,9 @@ export default function getEntryComponentForLoginType(loginType: AuthType): ISta
return MsisdnAuthEntry;
case AuthType.Terms:
return TermsAuthEntry;
case AuthType.RegistrationToken:
case AuthType.UnstableRegistrationToken:
return RegistrationTokenAuthEntry;
case AuthType.Sso:
case AuthType.SsoUnstable:
return SSOAuthEntry;
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,8 @@
"Please enter the code it contains:": "Please enter the code it contains:",
"Code": "Code",
"Submit": "Submit",
"Enter a registration token.": "Enter a registration token.",
"Registration token": "Registration token",
"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",
"Enter password": "Enter password",
Expand Down