From f74f9e462c48d42a4918ca5472cb7547d1db660b Mon Sep 17 00:00:00 2001 From: Aleksey Gurianov Date: Thu, 12 Jul 2018 00:20:05 +0400 Subject: [PATCH] improve ux of login flow #157 --- web/app/components/root/root.jsx | 14 +++++++++----- web/iframe.html | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index 9a9f479f..04713530 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -111,18 +111,22 @@ export default class Root extends Component { onSignIn(provider) { const newWindow = window.open( - `${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent(location.href)}&site=${siteId}` + `${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent( + location.origin + location.pathname + '?selfClose' + )}&site=${siteId}` ); let secondsPass = 0; - const checkMsDelay = 100; + const checkMsDelay = 300; const checkInterval = setInterval(() => { + let shouldProceed; secondsPass += checkMsDelay; + try { + shouldProceed = newWindow.closed || secondsPass > 30000; + } catch (e) {} - if (newWindow.location.origin === location.origin || secondsPass > 30000) { + if (shouldProceed) { clearInterval(checkInterval); - secondsPass = 0; - newWindow.close(); api .getUser() diff --git a/web/iframe.html b/web/iframe.html index bc7d0933..5c841c04 100644 --- a/web/iframe.html +++ b/web/iframe.html @@ -5,6 +5,11 @@ remark42 +