Skip to content

Commit

Permalink
fix: added source for oauth register and login method
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek9503 committed Oct 18, 2024
1 parent f472438 commit 5de79e8
Showing 1 changed file with 9 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

0 comments on commit 5de79e8

Please sign in to comment.