From 794cc0fc6c22a43f88b8cc8a498c9380ed3ed7fe Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 27 Apr 2017 19:09:38 +0700 Subject: [PATCH] Support login on all IOS browsers --- client/coral-framework/actions/auth.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index e112b2b6c..7b3f089ba 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -39,10 +39,21 @@ export const showSignInDialog = () => dispatch => { 'menubar=0,resizable=0,width=500,height=550,top=200,left=500' ); - signInPopUp.onbeforeunload = () => { - dispatch(checkLogin()); - fetchMe(); + // Workaround odd behavior in older WebKit versions, where + // onunload is called twice. (Encountered in IOS 8.3) + let loaded = false; + signInPopUp.onload = () => { + loaded = true; }; + + // Use `onunload` instead of `onbeforeunload` which is not supported in IOS Safari. + signInPopUp.onunload = () => { + if (loaded) { + dispatch(checkLogin()); + fetchMe(); + } + }; + dispatch({type: actions.SHOW_SIGNIN_DIALOG}); }; export const hideSignInDialog = () => dispatch => {