Skip to content

Commit

Permalink
Merge pull request #79 from mrodz/master
Browse files Browse the repository at this point in the history
Patch CI run missing env vars
  • Loading branch information
mrodz authored May 31, 2024
2 parents 42b828d + 91c3f57 commit 967ce45
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ on:
env:
TAURI_PRIVATE_KEY: ${{secrets.TAURI_PRIVATE_KEY}}
TAURI_KEY_PASSWORD: ${{secrets.TAURI_KEY_PASSWORD}}
AUTH_SERVER_URL: ${{secrets.AUTH_SERVER_URL}}
PUBLIC_FIREBASE_CLIENT_ID: ${{vars.PUBLIC_FIREBASE_CLIENT_ID}}
PUBLIC_GITHUB_CLIENT_ID: ${{vars.PUBLIC_GITHUB_CLIENT_ID}}
PUBLIC_TWITTER_CLIENT_ID: ${{vars.PUBLIC_TWITTER_CLIENT_ID}}


jobs:
publish-tauri:
environment: production
Expand Down
9 changes: 4 additions & 5 deletions webview/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
signInWithCredential,
type UserCredential
} from 'firebase/auth';
import { FIREBASE_CLIENT_ID, GITHUB_CLIENT_ID, TWITTER_CLIENT_ID } from './secrets';
import type { GithubOAuthAccessTokenExchange } from '$lib';
import { env } from '$env/dynamic/public'

async function googleSignIn(payload: string): Promise<UserCredential> {
const url = new URL(payload);
Expand Down Expand Up @@ -59,7 +59,7 @@ function openGoogleSignIn(port: string): Promise<void> {
return open(
'https://accounts.google.com/o/oauth2/auth?' +
'response_type=token&' +
`client_id=${FIREBASE_CLIENT_ID}&` +
`client_id=${env.PUBLIC_FIREBASE_CLIENT_ID}&` +
`redirect_uri=http%3A//127.0.0.1%3A${port}&` +
'scope=email%20profile&' +
'prompt=consent'
Expand All @@ -72,7 +72,7 @@ function openGoogleSignIn(port: string): Promise<void> {
function openGithubSignIn(port: string): Promise<void> {
return open(
'https://github.com/login/oauth/authorize?' +
`client_id=${GITHUB_CLIENT_ID}&` +
`client_id=${env.PUBLIC_GITHUB_CLIENT_ID}&` +
`redirect_uri=http%3A//127.0.0.1%3A${port}&` +
'scope=read:user%20user:email'
);
Expand All @@ -92,7 +92,7 @@ async function openTwitterSignIn(port: string): Promise<void> {
return open(
'https://twitter.com/i/oauth2/authorize?' +
'response_type=code&' +
`client_id=${TWITTER_CLIENT_ID}&` +
`client_id=${env.PUBLIC_TWITTER_CLIENT_ID}&` +
`redirect_uri=http%3A//127.0.0.1%3A${port}&` +
`code_challenge=${codeChallengeShortened}&` +
'code_challenge_method=plain&' +
Expand All @@ -105,7 +105,6 @@ export async function googleLogin(onSuccess: (userCredential: UserCredential) =>
let cancel = listen('oauth://url', async (data) => {
console.log(data);
try {

const credential = await googleSignIn(data.payload as string);
await onSuccess(credential);
} catch (e) {
Expand Down
3 changes: 0 additions & 3 deletions webview/src/lib/secrets.example.ts

This file was deleted.

23 changes: 20 additions & 3 deletions webview/src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
} from 'firebase/auth';
import { goto } from '$app/navigation';
import { slide } from 'svelte/transition';
import { getToastStore } from '@skeletonlabs/skeleton';
import { getModalStore, getToastStore } from '@skeletonlabs/skeleton';
import GoogleIcon from './GoogleIcon.svelte';
import TwitterIcon from './TwitterIcon.svelte';
import GitHubIcon from './GitHubIcon.svelte';
Expand All @@ -22,6 +22,7 @@
const queryParams = new URLSearchParams(window.location.search);
const next = queryParams.get('next') ?? '/';
const modalStore = getModalStore();
const toastStore = getToastStore();
const signInFunction = type().then((type) => {
Expand All @@ -48,7 +49,7 @@
message:
'You have used a different method of authentication in the past! Please try a different authentication platform.',
background: 'variant-filled-warning',
autohide: false,
autohide: false
});
} else {
console.error(error);
Expand All @@ -57,12 +58,20 @@
async function google() {
try {
modalStore.trigger({
type: 'alert',
title: 'Please wait, you are being authenticated',
body: 'Visit the tab that just opened and follow their instructions to log in',
meta: 'FIELDZ_AUTH_POPUP'
});
await googleLogin(
async (credential) => {
console.log($authStore.user, credential);
modalStore.close();
goto(next);
},
(e) => {
modalStore.close();
console.warn(e);
duplicatedMessage(e);
}
Expand All @@ -87,12 +96,20 @@
async function github() {
try {
modalStore.trigger({
type: 'alert',
title: 'Please wait, you are being authenticated',
body: 'Visit the tab that just opened and follow their instructions to log in',
meta: 'FIELDZ_AUTH_POPUP'
});
await githubLogin(
async (credential) => {
console.log($authStore.user, credential);
modalStore.close();
goto(next);
},
(e) => {
modalStore.close();
console.warn(e);
duplicatedMessage(e);
}
Expand Down Expand Up @@ -147,7 +164,7 @@
</button>
</div>

<div class="card mt-4 bg-yellow-300 p-4 text-center mx-auto md:w-2/3 xl:w-1/3">
<div class="card mx-auto mt-4 bg-yellow-300 p-4 text-center md:w-2/3 xl:w-1/3">
<header class="card-header font-bold">Temporary Notice</header>

<p>
Expand Down

0 comments on commit 967ce45

Please sign in to comment.