fix(auth): skipping special characters in the email query param

This commit is contained in:
Aminejv 2022-01-27 15:01:36 +01:00
parent 20d17b1881
commit 6590a3a096
3 changed files with 9 additions and 6 deletions

View File

@ -103,7 +103,9 @@ export default class CTATransition extends React.Component {
const currentURL = Strings.getCurrentURL(this.props.page?.params);
this.props.onAction({
type: "NAVIGATE",
href: `/_/auth?tab=signin&email=${emailOrUsername}&redirect=${encodeURI(currentURL)}`,
href: `/_/auth?tab=signin&email=${encodeURIComponent(emailOrUsername)}&redirect=${encodeURI(
currentURL
)}`,
});
this._handleClose();
};
@ -112,7 +114,9 @@ export default class CTATransition extends React.Component {
const currentURL = Strings.getCurrentURL(this.props.page?.params);
this.props.onAction({
type: "NAVIGATE",
href: `/_/auth?tab=signup&email=${email}&redirect=${encodeURI(currentURL)}`,
href: `/_/auth?tab=signup&email=${encodeURIComponent(email)}&redirect=${encodeURI(
currentURL
)}`,
});
this._handleClose();
};

View File

@ -847,7 +847,7 @@ export default function IndexPage() {
return errors;
},
onSubmit: async ({ email }) => {
window.open(`/_/auth?tab=signup&email=${email}`, "_self");
window.open(`/_/auth?tab=signup&email=${encodeURIComponent(email)}`, "_self");
},
});

View File

@ -161,10 +161,9 @@ const AuthScene = ({ onAuthenticate, onTwitterAuthenticate, page, onAction, ...p
);
}
// NOTE(amine): if the user goes back, we should prefill the email
const emailParam = page?.params?.email ? decodeURIComponent(page?.params?.email) : "";
const initialEmail =
prevScene === "signin" && context.emailOrUsername
? context.emailOrUsername
: page?.params?.email || "";
prevScene === "signin" && context.emailOrUsername ? context.emailOrUsername : emailParam;
return (
<Initial