diff --git a/src/pages/Auth/oauth-redirect/OauthRedirect.svelte b/src/pages/Auth/oauth-redirect/OauthRedirect.svelte index 7a66945..5519df0 100644 --- a/src/pages/Auth/oauth-redirect/OauthRedirect.svelte +++ b/src/pages/Auth/oauth-redirect/OauthRedirect.svelte @@ -4,14 +4,19 @@ import Redirect from '../redirect/Redirect.svelte'; import constants from '$lib/utils/constants'; + let userFromDesktop = localStorage.getItem('isUserFromDesktop'); + + onMount(() => { const urlParams = new URLSearchParams(window.location.search); const accessToken = urlParams.get('accessToken'); const refreshToken = urlParams.get('refreshToken'); const source = urlParams.get('source'); const sparrowRedirect = `sparrow://?accessToken=${accessToken}&refreshToken=${refreshToken}&event=${source}&method=google`; + const sparrowWebRedirect = constants.SPARROW_WEB_URL +`?accessToken=${accessToken}&refreshToken=${refreshToken}&event=${source}&method=google`; if (accessToken && refreshToken) { + if(userFromDesktop === "true"){ setTimeout(() => { let data = JSON.parse(window.atob(accessToken?.split('.')[1])); redirectRules.title = `Welcome ${data.name}`; @@ -27,6 +32,10 @@ }; }, constants.API_REDIRECT_TIMEOUT); } + else{ + navigate(sparrowWebRedirect) + } + } }); let redirectRules = { title: 'Welcome to Sparrow!', diff --git a/src/pages/Auth/verify-email/VerifyEmail.svelte b/src/pages/Auth/verify-email/VerifyEmail.svelte index 2cc8956..fbf0a27 100644 --- a/src/pages/Auth/verify-email/VerifyEmail.svelte +++ b/src/pages/Auth/verify-email/VerifyEmail.svelte @@ -14,6 +14,7 @@ import AngleUp from '$lib/assets/angle-up.svelte'; import BgContainer from '$lib/components/bgContainer/BgContainer.svelte'; import Redirect from '../redirect/Redirect.svelte'; + import constants from '$lib/utils/constants'; export let id: string; let seconds = 60; @@ -74,6 +75,10 @@ let emailText: string = id || ''; + + let userFromDesktop = localStorage.getItem('isUserFromDesktop'); + + const handleVerificationCode = () => { verifyCode = verificationCode1 + @@ -498,6 +503,9 @@ const accessToken = response?.data.accessToken?.token; const refreshToken = response?.data.refreshToken?.token; const sparrowRedirect = `sparrow://?accessToken=${accessToken}&refreshToken=${refreshToken}&response=${JSON.stringify(response.data)}&event=register&method=email`; + const sparrowWebRedirect = constants.SPARROW_WEB_URL +`?accessToken=${accessToken}&refreshToken=${refreshToken}&response=${JSON.stringify(response)}&event=register&method=email`; + + if(userFromDesktop === "true"){ setTimeout(() => { let data = JSON.parse(window.atob(accessToken?.split('.')[1])); redirectRules.title = `Welcome ${data.name.split(' ')[0]}`; @@ -513,6 +521,11 @@ }, 5000); } + else{ + navigate(sparrowWebRedirect); + } + } + verifyCodeLoader = false; }} />