Skip to content

Commit

Permalink
Merge pull request #72 from sparrowapp-dev/fix/fixed-source-for-register
Browse files Browse the repository at this point in the history
fix: Fixed source missing  in register event
  • Loading branch information
Astitva877 authored Oct 18, 2024
2 parents 4884d01 + 5de79e8 commit 94f6321
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pages/Auth/oauth-redirect/OauthRedirect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -27,6 +32,10 @@
};
}, constants.API_REDIRECT_TIMEOUT);
}
else{
navigate(sparrowWebRedirect)
}
}
});
let redirectRules = {
title: 'Welcome to Sparrow!',
Expand Down
13 changes: 13 additions & 0 deletions src/pages/Auth/verify-email/VerifyEmail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,6 +75,10 @@
let emailText: string = id || '';
let userFromDesktop = localStorage.getItem('isUserFromDesktop');
const handleVerificationCode = () => {
verifyCode =
verificationCode1 +
Expand Down Expand Up @@ -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]}`;
Expand All @@ -513,6 +521,11 @@
}, 5000);
}

else{
navigate(sparrowWebRedirect);
}
}

verifyCodeLoader = false;
}}
/>
Expand Down

0 comments on commit 94f6321

Please sign in to comment.