Skip to content

Commit

Permalink
Merge pull request #76 from sparrowapp-dev/fix/handle-cancel-event-go…
Browse files Browse the repository at this point in the history
…ogle-oauth

fix: handle cancel event google oauth
  • Loading branch information
Astitva877 authored Nov 12, 2024
2 parents a50b41b + c3a715f commit c3e8190
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/pages/Auth/oauth-redirect/OauthRedirect.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<script>
<script lang="ts">
import { onMount } from 'svelte';
import { navigate } from 'svelte-navigator';
import Redirect from '../redirect/Redirect.svelte';
import constants from '$lib/utils/constants';
let userFromDesktop = localStorage.getItem('isUserFromDesktop');
let accessToken = "";
let refreshToken = "";
onMount(() => {
const urlParams = new URLSearchParams(window.location.search);
const accessToken = urlParams.get('accessToken');
const refreshToken = urlParams.get('refreshToken');
accessToken = urlParams.get('accessToken') as string;
refreshToken = urlParams.get('refreshToken') as string;
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`;
Expand All @@ -36,6 +37,14 @@
navigate(sparrowWebRedirect)
}
}
else{
if(userFromDesktop === "true"){
navigate("/init")
}
else{
navigate("/init?source=web")
}
}
});
let redirectRules = {
title: 'Welcome to Sparrow!',
Expand All @@ -48,12 +57,14 @@
};
</script>

<Redirect
title={redirectRules.title}
description={redirectRules.description}
message={redirectRules.message}
isSpinner={redirectRules.isSpinner}
buttonText={redirectRules.buttonText}
buttonClick={redirectRules.buttonClick}
loadingMessage={redirectRules.loadingMessage}
/>
{#if accessToken && refreshToken}
<Redirect
title={redirectRules.title}
description={redirectRules.description}
message={redirectRules.message}
isSpinner={redirectRules.isSpinner}
buttonText={redirectRules.buttonText}
buttonClick={redirectRules.buttonClick}
loadingMessage={redirectRules.loadingMessage}
/>
{/if}

0 comments on commit c3e8190

Please sign in to comment.