Skip to content

Commit 9632aad

Browse files
committed
feat: ✨ Add secret OIDC account linking support
1 parent 32c13d4 commit 9632aad

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

layouts/app.vue

+20-2
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,34 @@
4242

4343
<script setup lang="ts">
4444
import { OverlayScrollbarsComponent } from "#imports";
45-
const tokenData = useTokenData();
4645
const { width } = useWindowSize();
4746
48-
const { n } = useMagicKeys();
47+
const { n, o_i_d_c } = useMagicKeys();
48+
const tokenData = useTokenData();
49+
const client = useMegalodon(tokenData);
50+
const providers = await useOAuthProviders();
4951
5052
watchEffect(async () => {
5153
if (n.value) {
5254
// Wait 50ms
5355
await new Promise((resolve) => setTimeout(resolve, 50));
5456
useEvent("composer:open");
5557
}
58+
if (o_i_d_c.value) {
59+
const response = await fetch(
60+
new URL(
61+
`/oauth/link?issuer=${providers.value[0].id}`,
62+
client.value?.baseUrl,
63+
),
64+
{
65+
headers: {
66+
Authorization: `Bearer ${tokenData.value?.access_token}`,
67+
},
68+
},
69+
);
70+
71+
const json = await response.json();
72+
window.location.href = json.link;
73+
}
5674
});
5775
</script>

0 commit comments

Comments
 (0)