Skip to content

Commit

Permalink
fix: broken desktop login (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlienard authored Aug 12, 2023
1 parent b74f0a0 commit 2f8ec44
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/common/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class:icon
class:loading
class:disabled
{href}
href={disabled ? '#' : href}
target={external ? '_blank' : undefined}
rel={external ? 'noreferrer' : undefined}
on:click={handleClick}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/dashboard/Banner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { cubicInOut } from 'svelte/easing';
import { browser } from '$app/environment';
import { page } from '$app/stores';
import { openDesktopApp } from '~/lib/helpers';
import { CrossIcon, ExclamationMarkIcon } from '~/lib/icons';
import { DownloadButton } from '../landing';
Expand All @@ -29,7 +30,7 @@
}, 500);
// Open the app with the access token
window.location.href = `gitlight://github_access_token=${githubAccessToken}&gitlab_access_token=${gitlabAccessToken}`;
openDesktopApp({ githubAccessToken, gitlabAccessToken });
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/createNotificationData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { page } from '$app/stores';
import { getDiscussionUrl } from '$lib/helpers/searchNotificationHelper';
import { getDiscussionUrl } from '~/lib/helpers';
import {
ClosedIssueIcon,
CommitIcon,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export * from './fetchGitlab';
export * from './formatRelativeDate';
export * from './getAppVersion';
export * from './getIcon';
export * from './priorities';
export * from './lightenColor';
export * from './openDesktopApp';
export * from './priorities';
export * from './removeMarkdownSymbols';
export * from './searchNotificationHelper';
export * from './storage';
13 changes: 13 additions & 0 deletions src/lib/helpers/openDesktopApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function openDesktopApp({
githubAccessToken,
gitlabAccessToken
}: {
githubAccessToken?: string | null;
gitlabAccessToken?: string | null;
}) {
if (githubAccessToken || gitlabAccessToken) {
window.location.href = `gitlight://github_access_token=${
githubAccessToken || ''
}&gitlab_access_token=${gitlabAccessToken || ''}`;
}
}
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Listen for scheme request on desktop app
listen('scheme-request', ({ payload }) => {
const scheme = (payload as string).split('&');
const scheme = (payload as string).replace('gitlight://', '').split('&');
let githubAccessToken = scheme[0].split('=')[1];
if (githubAccessToken) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import { browser } from '$app/environment';
import { fetchGithub, fetchGitlab, storage } from '~/lib/helpers';
import { fetchGithub, fetchGitlab, openDesktopApp, storage } from '~/lib/helpers';
import type { GithubUser, GitlabUser } from '~/lib/types';

import '~/styles/_reset.scss';
Expand Down Expand Up @@ -48,7 +48,7 @@ export async function load({ url }) {

// Open the app with the access token
if (url.searchParams.has('from_app') && (githubAccessToken || gitlabAccessToken)) {
window.location.href = `gitlight://github_access_token=${githubAccessToken}&gitlab_access_token=${gitlabAccessToken}`;
openDesktopApp({ githubAccessToken, gitlabAccessToken });
}

// Remove access tokens from the URL
Expand Down

1 comment on commit 2f8ec44

@vercel
Copy link

@vercel vercel bot commented on 2f8ec44 Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.