From 246273a26c0dbcea06c1b7b2acf9e5500fdebb8f Mon Sep 17 00:00:00 2001 From: Bheem Date: Fri, 12 Jun 2020 11:42:25 +0530 Subject: [PATCH] desktop google login issues fixed --- .../Auth/components/LoginWithGoogleButton.js | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/containers/Auth/components/LoginWithGoogleButton.js b/src/containers/Auth/components/LoginWithGoogleButton.js index 68dbcfee8..95f7fa309 100644 --- a/src/containers/Auth/components/LoginWithGoogleButton.js +++ b/src/containers/Auth/components/LoginWithGoogleButton.js @@ -32,6 +32,13 @@ class LoginWithGoogleButton extends Component { this.stateStr = "koiu7869bvfvyu9KJ678HGtgybO8"; } + componentDidMount(){ + if(isElectron && isElectron()){ + // Initialize Firebase + const firebaseConfig = OAuthConfig.firebaseConfig; + firebase.initializeApp(firebaseConfig); + } + } doLogin = async () => { this.props.startSocialAuth(); this.props.displaySocialAuthMsg(true); @@ -41,29 +48,26 @@ class LoginWithGoogleButton extends Component { if(isElectron && isElectron()){ // firbase code start const id = new Date().getTime(); - - // Initialize Firebase - const firebaseConfig = OAuthConfig.firebaseConfig; - firebase.initializeApp(firebaseConfig); - await firebase.database().ref(`ot-auth-codes/${id}`).set({ authToken: 0, type:'google' }); const oneTimeCodeRef = firebase.database().ref(`ot-auth-codes/${id}`) oneTimeCodeRef.on('value', async snapshot => { const resData = snapshot.val(); - console.log('[DT] authToken::Res::',resData); - if(resData.authToken!==0){ - console.log('[DT] authToken::',resData.authToken); + console.log('[DT] authToken resData::',resData); + if(resData){ + if(resData.authToken!==0){ + console.log('[DT] authToken::',resData.authToken); - //remove firebase ref key after success authenticate - oneTimeCodeRef.remove() - .then(function() { - console.log("[DT] Remove succeeded.") - }) - .catch(function(error) { - console.log("[DT] Remove failed: " + error.message) - }); - - this.props.navigateToSignUp(resData.authToken, 'GOOGLEPLUS'); + //remove firebase ref key after success authenticate + oneTimeCodeRef.remove() + .then(function() { + console.log("[DT] Remove succeeded.") + }) + .catch(function(error) { + console.log("[DT] Remove failed: " + error.message) + }); + + this.props.navigateToSignUp(resData.authToken, 'GOOGLEPLUS'); + } } }); -- GitLab