Compare commits
5 commits
11856a0f04
...
b31ef2b5b8
Author | SHA1 | Date | |
---|---|---|---|
|
b31ef2b5b8 | ||
|
281d99a4da | ||
|
2078b6ed4d | ||
|
a53fc0cf29 | ||
|
9628d5e48e |
5 changed files with 43 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
creator,followers,id
|
creator,followers,id
|
||||||
" ColdFusion",4850000,UC4QZ_LsYcvcq7qOsOhpAX4A
|
ColdFusion,4850000,UC4QZ_LsYcvcq7qOsOhpAX4A
|
||||||
" Veritasium",15000000,UCHnyfMqiRRG1u-2MsSQLbXA
|
Veritasium,15000000,UCHnyfMqiRRG1u-2MsSQLbXA
|
||||||
Vsause,22000000,C6nSFpj9HTCZ5t-N3Rm3-HA
|
Vsause,22000000,C6nSFpj9HTCZ5t-N3Rm3-HA
|
|
16
src/pages/account/anon/end.astro
Normal file
16
src/pages/account/anon/end.astro
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
import Base from "@layouts/Base.astro"
|
||||||
|
---
|
||||||
|
|
||||||
|
<Base Title="Supabase Demo">
|
||||||
|
<center>
|
||||||
|
<h2>End Anonymous Session</h2>
|
||||||
|
<p>You're currently in an anonymous session, these can't be logged back into. If you choose to confirm logging out, <span style="color: red">your anonymous account will be deleted immediately, this action can't be undone</span>.</p>
|
||||||
|
<p>If you're not logged into an anomymous account, try clearing your browser cookies for this website.</p>
|
||||||
|
<!-- <p>If you want to keep your anonymous account, you can convert it to a regular account, which will require setting up an email and password for it.</p> -->
|
||||||
|
<div style="display: flex; gap: 6px; justify-content: center;">
|
||||||
|
<!-- <form action="/" method="get"><button>Convert Account</button></form> -->
|
||||||
|
<form action="/api/account/anon-delete" method="post"><button>Confirm Logout</button></form>
|
||||||
|
</div>
|
||||||
|
</center>
|
||||||
|
</Base>
|
15
src/pages/api/account/anon-delete.ts
Normal file
15
src/pages/api/account/anon-delete.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import type { APIRoute } from "astro"
|
||||||
|
import { supabase } from "@library/supabase"
|
||||||
|
|
||||||
|
export const POST: APIRoute = async ({ cookies, redirect }) => {
|
||||||
|
|
||||||
|
// https://supabase.com/docs/reference/javascript/auth-updateuser?example=update-the-users-metadata
|
||||||
|
const { error } = await supabase.rpc('delete_user');
|
||||||
|
cookies.delete("anonymous-session", { path: "/" })
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return new Response(error.message, { status: 500 })
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect("/api/auth/signout")
|
||||||
|
}
|
|
@ -10,5 +10,5 @@ export const POST: APIRoute = async ({ redirect }) => {
|
||||||
return new Response(error.message, { status: 500 })
|
return new Response(error.message, { status: 500 })
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect("/signout")
|
return redirect("/api/auth/signout")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,13 @@ import { supabase } from "@library/supabase"
|
||||||
import type { Provider } from "@supabase/supabase-js"
|
import type { Provider } from "@supabase/supabase-js"
|
||||||
|
|
||||||
export const GET: APIRoute = async ({ cookies, redirect }) => {
|
export const GET: APIRoute = async ({ cookies, redirect }) => {
|
||||||
|
|
||||||
|
if(cookies.get('anonymous-session')) {
|
||||||
|
return redirect('/account/anon/end')
|
||||||
|
} else {
|
||||||
cookies.delete("sb-access-token", { path: "/" })
|
cookies.delete("sb-access-token", { path: "/" })
|
||||||
cookies.delete("sb-refresh-token", { path: "/" })
|
cookies.delete("sb-refresh-token", { path: "/" })
|
||||||
const { error } = await supabase.auth.signOut()
|
const { error } = await supabase.auth.signOut()
|
||||||
return redirect("/signin")
|
}
|
||||||
|
return redirect("/")
|
||||||
}
|
}
|
Loading…
Reference in a new issue