WIP 3752f008
Steve · 2024-09-20 06:24 4 file(s) · +26 −40
astro.config.ts +6 −0
33 33
	vite: {
34 34
		define: {
35 35
			"process.env.NODE_ENV": `'${process.env.NODE_ENV}'`,
36 +
			"process.env.PUBLIC_SUPABASE_URL": JSON.stringify(
37 +
				process.env.PUBLIC_SUPABASE_URL,
38 +
			),
39 +
			"process.env.PUBLIC_SUPABASE_ANON_KEY": JSON.stringify(
40 +
				process.env.PUBLIC_SUPABASE_ANON_KEY,
41 +
			),
36 42
		},
37 43
	},
38 44
	output: "hybrid",
src/components/SignInButton.tsx +16 −16
1 -
// import { supabase } from "src/lib/supabase";
1 +
import { supabase } from "src/lib/supabase";
2 2
3 -
// export function SignInButton() {
4 -
// 	async function signInWithGithub() {
5 -
// 		await supabase.auth.signInWithOAuth({
6 -
// 			provider: "github",
7 -
// 			options: {
8 -
// 				redirectTo: "https://stevedylan.dev/auth/callback",
9 -
// 			},
10 -
// 		});
11 -
// 	}
3 +
export function SignInButton() {
4 +
	async function signInWithGithub() {
5 +
		await supabase.auth.signInWithOAuth({
6 +
			provider: "github",
7 +
			options: {
8 +
				redirectTo: "https://stevedylan.dev/auth/callback",
9 +
			},
10 +
		});
11 +
	}
12 12
13 -
// 	return (
14 -
// 		<button type="button" onClick={signInWithGithub}>
15 -
// 			Sign In
16 -
// 		</button>
17 -
// 	);
18 -
// }
13 +
	return (
14 +
		<button type="button" onClick={signInWithGithub}>
15 +
			Sign In
16 +
		</button>
17 +
	);
18 +
}
src/lib/supabase.ts +2 −2
1 1
import { createClient } from "@supabase/supabase-js";
2 2
3 3
export const supabase = createClient(
4 -
	"https://rbhamoqatlwbdxlydlcw.supabase.com",
5 -
	"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJiaGFtb3FhdGx3YmR4bHlkbGN3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjY3MzkwNDEsImV4cCI6MjA0MjMxNTA0MX0.prA8jmaA5d-mK-LVyBWCvsWb6g2kV6yHQFoLYxRNgW8",
4 +
	import.meta.env.PUBLIC_SUPABASE_URL,
5 +
	import.meta.env.PUBLIC_SUPABASE_ANON_KEY,
6 6
);
src/pages/log.astro +2 −22
1 1
---
2 2
import PageLayout from "@/layouts/Base";
3 +
import { SignInButton } from "src/components/SignInButton";
3 4
4 5
const meta = {
5 6
	title: "Log",
7 8
};
8 9
---
9 10
10 -
<script>
11 -
  import { createClient } from '@supabase/supabase-js';
12 -
13 -
  const supabase = createClient(
14 -
    Astro.locals.runtime.env.PUBLIC_SUPABASE_URL,
15 -
    Astro.locals.runtime.env.PUBLIC_SUPABASE_ANON_KEY
16 -
  );
17 -
18 -
  async function signInWithGithub() {
19 -
    await supabase.auth.signInWithOAuth({
20 -
      provider: "github",
21 -
      options: {
22 -
        redirectTo: "https://stevedylan.dev/auth/callback",
23 -
      },
24 -
    });
25 -
  }
26 -
27 -
  document.getElementById('signInButton').addEventListener('click', signInWithGithub);
28 -
</script>
29 -
30 -
31 11
<PageLayout meta={meta}>
32 12
	<div class="space-y-6">
33 -
	<button type="button" id="signInButton">Sign In</button>
13 +
	<SignInButton />
34 14
	</div>
35 15
</PageLayout>