mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
feat: ✨ Add secret OIDC account linking support
This commit is contained in:
parent
32c13d4c99
commit
9632aadbde
|
|
@ -42,10 +42,12 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { OverlayScrollbarsComponent } from "#imports";
|
||||
const tokenData = useTokenData();
|
||||
const { width } = useWindowSize();
|
||||
|
||||
const { n } = useMagicKeys();
|
||||
const { n, o_i_d_c } = useMagicKeys();
|
||||
const tokenData = useTokenData();
|
||||
const client = useMegalodon(tokenData);
|
||||
const providers = await useOAuthProviders();
|
||||
|
||||
watchEffect(async () => {
|
||||
if (n.value) {
|
||||
|
|
@ -53,5 +55,21 @@ watchEffect(async () => {
|
|||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
useEvent("composer:open");
|
||||
}
|
||||
if (o_i_d_c.value) {
|
||||
const response = await fetch(
|
||||
new URL(
|
||||
`/oauth/link?issuer=${providers.value[0].id}`,
|
||||
client.value?.baseUrl,
|
||||
),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokenData.value?.access_token}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const json = await response.json();
|
||||
window.location.href = json.link;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in a new issue