Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
fix: discord oauth (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmaribojoc authored Dec 16, 2022
1 parent 2c8bbe8 commit abb7f4b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pages/quiz/results/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@
],
});
onMounted(() => {
onMounted(async () => {
const { url, publicKey } = useRuntimeConfig().public.supabase;
supabase = createClient(url, publicKey);
userSession.value = supabase.auth.session();
const session = await supabase.auth.getSession();
userSession.value = session.data.session;
supabase.auth.onAuthStateChange((event, session) => {
userSession.value = session;
Expand All @@ -90,17 +93,15 @@
return;
}
const { session } = await supabase.auth.signIn(
{
provider: 'discord',
},
{
const { data } = await supabase.auth.signInWithOAuth({
provider: 'discord',
options: {
redirectTo: window.location.href,
scopes: 'identify email',
},
);
});
userSession.value = session;
userSession.value = data.session;
}
async function claimBadge() {
Expand All @@ -111,7 +112,7 @@
await $fetch<ApiQuizResponse>(ApiUrl.QuizClaimBadge, {
method: 'POST',
body: {
accessToken: userSession.value?.access_token,
accessToken: userSession.value?.provider_token,
resultId: response.value.id,
},
})
Expand Down

0 comments on commit abb7f4b

Please sign in to comment.