From 3e5737863198f49a43a1b67f2b7c369a953614ad Mon Sep 17 00:00:00 2001 From: Ibragim/Parviz Bekliev Date: Tue, 9 Feb 2021 12:08:40 +0300 Subject: [PATCH] fix / sso: after complete login via token make sure to delete only loginToken query-param from the window.location api. Related to https://github.com/vector-im/element-web/pull/16292 Signed-off-by: Bekliev Parviz --- src/vector/app.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vector/app.tsx b/src/vector/app.tsx index 9df1d8c6c4..a8eb81a5a8 100644 --- a/src/vector/app.tsx +++ b/src/vector/app.tsx @@ -120,8 +120,11 @@ 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); - parsedUrl.search = ""; + const parsedUrl = url.parse(window.location.href, true); + + parsedUrl.search = null; // to make `url.format` ignores `search` property and uses `query` instead + delete parsedUrl.query['loginToken']; + const formatted = url.format(parsedUrl); console.log(`Redirecting to ${formatted} to drop loginToken from queryparams`); window.history.replaceState(null, "", formatted);