2025-04-10 18:44:53 +02:00
|
|
|
<template>
|
|
|
|
|
<Dialog>
|
|
|
|
|
<DialogTrigger as-child>
|
|
|
|
|
<slot />
|
|
|
|
|
</DialogTrigger>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle>Accounts</DialogTitle>
|
|
|
|
|
<DialogDescription class="sr-only">
|
|
|
|
|
Manage your accounts and settings.
|
|
|
|
|
</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
2025-08-28 07:41:51 +02:00
|
|
|
<div v-if="authStore.identities.length > 0" class="grid gap-4 py-2">
|
|
|
|
|
<div v-for="identity of authStore.identities" :key="identity.account.id"
|
2025-04-10 18:44:53 +02:00
|
|
|
class="grid grid-cols-[1fr_auto] has-[>[data-switch]]:grid-cols-[1fr_auto_auto] gap-2">
|
|
|
|
|
<TinyCard :account="identity.account" :domain="identity.instance.domain" naked />
|
2025-08-28 07:41:51 +02:00
|
|
|
<Button data-switch v-if="authStore.identity?.id !== identity.id"
|
|
|
|
|
@click="authStore.setActiveIdentity(identity.id)" variant="outline">
|
2025-04-10 18:44:53 +02:00
|
|
|
Switch
|
|
|
|
|
</Button>
|
2025-08-28 07:41:51 +02:00
|
|
|
<Button @click="signOutAction(identity.id)" variant="outline" size="icon"
|
2025-04-10 18:44:53 +02:00
|
|
|
:title="m.sharp_big_mallard_reap()">
|
|
|
|
|
<LogOut />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<p class="text-sm text-muted-foreground">
|
|
|
|
|
Log in to or register an account on your favourite instance.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<DialogFooter>
|
|
|
|
|
<Button :as="NuxtLink" href="/register" variant="outline">
|
|
|
|
|
<UserPlus />
|
|
|
|
|
{{ m.honest_few_baboon_pop() }}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button @click="signInAction">
|
|
|
|
|
<LogIn />
|
|
|
|
|
{{ m.sunny_pink_hyena_walk() }}
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogFooter>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-05-26 11:19:15 +02:00
|
|
|
import { LogIn, LogOut, UserPlus } from "lucide-vue-next";
|
2025-04-10 18:44:53 +02:00
|
|
|
import { toast } from "vue-sonner";
|
2025-06-26 22:39:02 +02:00
|
|
|
import { NuxtLink } from "#components";
|
2025-04-10 18:44:53 +02:00
|
|
|
import TinyCard from "~/components/profiles/tiny-card.vue";
|
|
|
|
|
import { Button } from "~/components/ui/button";
|
|
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogDescription,
|
|
|
|
|
DialogFooter,
|
|
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogTrigger,
|
|
|
|
|
} from "~/components/ui/dialog";
|
2025-07-16 07:48:39 +02:00
|
|
|
import * as m from "~~/paraglide/messages.js";
|
2025-04-10 18:44:53 +02:00
|
|
|
|
2025-08-28 07:41:51 +02:00
|
|
|
const authStore = useAuthStore();
|
|
|
|
|
const signInAction = async () => {
|
|
|
|
|
const instance = await askForInstance();
|
2025-04-10 18:44:53 +02:00
|
|
|
|
2025-08-28 07:41:51 +02:00
|
|
|
const id = toast.loading(m.level_due_ox_greet());
|
2025-04-10 18:44:53 +02:00
|
|
|
|
2025-08-28 07:41:51 +02:00
|
|
|
try {
|
|
|
|
|
await authStore.startSignIn(instance);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
2025-04-10 18:44:53 +02:00
|
|
|
toast.dismiss(id);
|
|
|
|
|
}
|
2025-08-28 07:41:51 +02:00
|
|
|
};
|
2025-04-10 18:44:53 +02:00
|
|
|
|
2025-08-28 07:41:51 +02:00
|
|
|
const signOutAction = async (identityId: string) => {
|
|
|
|
|
const id = toast.loading("Signing out...");
|
2025-04-10 18:44:53 +02:00
|
|
|
|
2025-08-28 07:41:51 +02:00
|
|
|
await authStore.signOut(identityId);
|
|
|
|
|
toast.dismiss(id);
|
|
|
|
|
toast.success("Signed out");
|
2025-04-10 18:44:53 +02:00
|
|
|
};
|
|
|
|
|
</script>
|