feat: use discord_id from discord sso for role grant (#6326)

* feat: properly use labrinth's linked discord accts sso for discord bot

* Update email for fixture user in SQL insert

Signed-off-by: Calum H. <calum@modrinth.com>

* fix: rev changes

* fix: copy on email

* fix: lint

* fix: rev

* fix: lint

---------

Signed-off-by: Calum H. <calum@modrinth.com>
This commit is contained in:
Calum H.
2026-06-09 17:33:07 +00:00
committed by GitHub
parent bc5a761312
commit 543d25e2d6
20 changed files with 726 additions and 59 deletions
+62
View File
@@ -0,0 +1,62 @@
<script setup lang="ts">
import { injectModrinthClient } from '@modrinth/ui'
import { getAuthUrl } from '~/composables/auth.js'
definePageMeta({
layout: 'empty',
middleware: 'auth',
})
const route = useRoute()
const auth = await useAuth()
const client = injectModrinthClient()
const error = ref<unknown>(null)
const isLinkedCallback = computed(() => route.query.callback === 'linked')
onMounted(async () => {
if (isLinkedCallback.value) return
try {
if (!auth.value.user?.auth_providers?.includes('discord')) {
window.location.href = `${getAuthUrl('discord', '/discord/link')}&token=${auth.value.token}`
return
}
const res = await client.labrinth.auth_internal.createDiscordCommunityLink()
window.location.href = res.url
} catch (err) {
error.value = err
}
})
</script>
<template>
<section class="discord-link-container universal-card">
<h1>{{ isLinkedCallback ? 'Modrinth account linked' : 'Linking Discord' }}</h1>
<p v-if="isLinkedCallback">Your Modrinth account has been linked to the Discord server.</p>
<p v-else-if="!error">Connecting your Modrinth account to the Discord server...</p>
<p v-else>Discord linking failed. Please try again later.</p>
</section>
</template>
<style scoped>
.discord-link-container {
width: 26rem;
max-width: calc(100% - 2rem);
margin: 1rem auto;
display: flex;
flex-direction: column;
gap: 2rem;
}
.discord-link-container h1 {
font-size: var(--font-size-xl);
margin: 0 0 -1rem 0;
color: var(--color-contrast);
}
.discord-link-container p {
margin: 0;
}
</style>