-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add supabase nuxt module, experiment with supabase oauth * fix: integrate with windows, fix mac security crate, prevent it to compile on windows * fix: deep link fixed for windows, js URL works differently on windows and macos, wtf? * feat: supabase oauth, internal without deeplink Had problem with deep link, failed to verify code. * feat: implement supabase oauth with deep link * update deno lock
- Loading branch information
1 parent
7ce224e
commit 7b9cc5c
Showing
24 changed files
with
4,521 additions
and
3,654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<script setup lang="ts"> | ||
import { Avatar, AvatarFallback, AvatarImage } from "@kksh/vue/avatar" | ||
import { Button } from "@kksh/vue/button" | ||
import { ArrowLeftIcon } from "@radix-icons/vue" | ||
import { onKeyStroke } from "@vueuse/core" | ||
import { toast } from "vue-sonner" | ||
const session = useSupabaseSession() | ||
const supabase = useSupabaseClient() | ||
const user = useSupabaseUser() | ||
onKeyStroke("Escape", (e) => { | ||
e.preventDefault() | ||
onBack() | ||
}) | ||
function onBack() { | ||
navigateTo("/") | ||
} | ||
const route = useRoute() | ||
onMounted(async () => { | ||
const code = route.query.code | ||
console.log("Exchange Code", code) | ||
if (code) { | ||
await supabase.auth.exchangeCodeForSession(code as string) | ||
} else { | ||
toast.error("No code found") | ||
} | ||
}) | ||
const avatarFallback = computed(() => { | ||
if (!session.value) return "?" | ||
const nameSplit = session.value?.user.user_metadata.name.split(" ").filter(Boolean) | ||
if (nameSplit.length > 1) { | ||
return nameSplit[0][0] + nameSplit.at(-1)[0] | ||
} else if (nameSplit.length === 1) { | ||
return nameSplit[0][0] | ||
} else { | ||
return "?" | ||
} | ||
}) | ||
function onSignOut() { | ||
supabase.auth.signOut() | ||
navigateTo("/auth") | ||
} | ||
</script> | ||
<template> | ||
<main class="container h-screen w-screen pt-10"> | ||
<Button variant="outline" size="icon" class="absolute left-2 top-2 z-50" @click="onBack"> | ||
<ArrowLeftIcon /> | ||
</Button> | ||
<div class="flex grow items-center justify-center pt-16"> | ||
<div class="flex flex-col items-center gap-4"> | ||
<span v-if="session" class="font-mono text-4xl font-bold">Welcome, You are Logged In</span> | ||
<span v-else class="font-mono text-4xl font-bold">You Are Not Logged In</span> | ||
<span flex flex-col items-center gap-5 text-xl> | ||
<Avatar v-if="session" class="h-32 w-32 border"> | ||
<AvatarImage :src="session?.user.user_metadata.avatar_url" alt="avatar" /> | ||
<AvatarFallback>{{ avatarFallback }}</AvatarFallback> | ||
</Avatar> | ||
<Button variant="outline" @click="onSignOut">Sign Out</Button> | ||
</span> | ||
</div> | ||
</div> | ||
</main> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<script setup lang="ts"> | ||
import { DEEP_LINK_PATH_AUTH_CONFIRM } from "@kksh/api" | ||
import { Button } from "@kksh/vue/button" | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle | ||
} from "@kksh/vue/card" | ||
import { ArrowLeftIcon } from "@radix-icons/vue" | ||
import { onKeyStroke } from "@vueuse/core" | ||
import { open } from "tauri-plugin-shellx-api" | ||
import { toast } from "vue-sonner" | ||
const supabase = useSupabaseClient() | ||
const session = useSupabaseSession() | ||
const redirectTo = DEEP_LINK_PATH_AUTH_CONFIRM | ||
// const redirectTo = "http://localhost:3000/auth/confirm" | ||
onKeyStroke("Escape", (e) => { | ||
e.preventDefault() | ||
onBack() | ||
}) | ||
function onBack() { | ||
navigateTo("/") | ||
} | ||
const signInWithOAuth = async (provider: "github" | "google") => { | ||
// console.log(`Login with ${provider} redirecting to ${redirectTo}`); | ||
const { error, data } = await supabase.auth.signInWithOAuth({ | ||
provider, | ||
options: { | ||
redirectTo, | ||
skipBrowserRedirect: true | ||
} | ||
}) | ||
console.log("Sign In With OAuth", data) | ||
if (error) { | ||
console.log(error) | ||
toast.error("Failed to sign in with OAuth", { description: error.message }) | ||
} else { | ||
data.url && open(data.url) | ||
} | ||
} | ||
onMounted(async () => { | ||
if (session.value) { | ||
// navigateTo("/") | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<main h-screen w-screen flex flex-col justify-center items-center> | ||
<Button variant="outline" size="icon" class="absolute left-2 top-2 z-50" @click="onBack"> | ||
<ArrowLeftIcon /> | ||
</Button> | ||
<!-- <Button @click="supabase.auth.signOut()">Sign Out</Button> --> | ||
<Card class="w-80"> | ||
<CardHeader class="space-y-1"> | ||
<CardTitle class="flex flex-col items-center text-2xl"> | ||
<div class="p-5"> | ||
<nuxt-img src="/img/logo.png" alt="Kunkun" class="h-12 w-12 invert" /> | ||
</div> | ||
<Button v-if="session" variant="outline" @click="supabase.auth.signOut()" | ||
>Sign Out</Button | ||
> | ||
<span v-else>Sign In</span> | ||
</CardTitle> | ||
<CardDescription></CardDescription> | ||
</CardHeader> | ||
<CardContent class="grid gap-4"> | ||
<div v-if="!session" class="grid grid-cols-2 place-items-center gap-4"> | ||
<Button variant="outline" size="lg" class="w-full" @click="signInWithOAuth('github')"> | ||
<Icon name="fa6-brands:github" class="h-5 w-5" /> | ||
</Button> | ||
<Button variant="outline" size="lg" class="w-full" @click="signInWithOAuth('google')"> | ||
<Icon name="logos:google-icon" class="h-5 w-5" /> | ||
</Button> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
</main> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
definePageMeta({ | ||
layout: false | ||
}) | ||
const session = useSupabaseSession() | ||
</script> | ||
|
||
<template> | ||
<MetadataLabel title="test" text="149.5%" /> | ||
<MetadataSeparator /> | ||
<MetadataLabel title="test" text="149.5%" /> | ||
<MetadataSeparator /> | ||
<MetadataLabel title="test" text="149.5%" /> | ||
<MetadataSeparator /> | ||
<MetadataLabel title="test" text="149.5%" /> | ||
<MetadataSeparator /> | ||
<div> | ||
<h1>dev</h1> | ||
<pre>session: {{ session }}</pre> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.