Skip to content

Commit

Permalink
fix / sso: switched from Node's url API to browser's URL.
Browse files Browse the repository at this point in the history
Related to element-hq#16292

Signed-off-by: Bekliev Parviz <[email protected]>
  • Loading branch information
bekliev committed Feb 11, 2021
1 parent 3e57378 commit ff7412d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/vector/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import React from 'react';
// this incidentally means we can forget our React imports in JSX files without penalty.
window.React = React;

import url from 'url';
import * as sdk from 'matrix-react-sdk';
import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg';
import {_td, newTranslatableError} from 'matrix-react-sdk/src/languageHandler';
Expand Down Expand Up @@ -120,14 +119,12 @@ function onTokenLoginCompleted() {
// if we did a token login, we're now left with the token, hs and is
// url as query params in the url; a little nasty but let's redirect to
// clear them.
const parsedUrl = url.parse(window.location.href, true);
const url = new URL(window.location.href);

parsedUrl.search = null; // to make `url.format` ignores `search` property and uses `query` instead
delete parsedUrl.query['loginToken'];
url.searchParams.delete('loginToken');

const formatted = url.format(parsedUrl);
console.log(`Redirecting to ${formatted} to drop loginToken from queryparams`);
window.history.replaceState(null, "", formatted);
console.log(`Redirecting to ${url.href} to drop loginToken from queryparams`);
window.history.replaceState(null, "", url.href);
}

export async function loadApp(fragParams: {}) {
Expand Down

0 comments on commit ff7412d

Please sign in to comment.