0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Fixed token handling in url for magic-link

closes https://github.com/TryGhost/members.js/issues/14

This adds handling of url update when signing-in with magic link by removing the token query param, which can cause accidental re-login on refresh.
This commit is contained in:
Rish 2020-04-23 20:46:14 +05:30
parent 72b8a376c6
commit 1fdc514c1f

View file

@ -9,8 +9,17 @@ function addRootDiv() {
document.body.appendChild(elem);
}
function handleTokenUrl() {
const url = new URL(window.location);
if (url.searchParams.get('token')) {
url.searchParams.delete('token');
window.history.replaceState({}, document.title, url.href);
}
}
function init(data) {
addRootDiv();
handleTokenUrl();
ReactDOM.render(
<React.StrictMode>
<App data={data} />