Line data Source code
1 1 : <template>
2 : <div class="user-settings-container h-full">
3 : <div class="flex h-full flex-col">
4 : <h2 class="mb-2 text-2xl font-bold">{{ $t('userSettings.title') }}</h2>
5 : <div class="mt-4 mb-3 border-t" />
6 :
7 : <!-- Normal User Panel -->
8 : <div v-if="isLoggedIn" class="flex flex-col gap-2">
9 : <UserAvatar
10 : v-if="userPhotoUrl"
11 : :label="$t('auth.login.userAvatar')"
12 : :photo-url="userPhotoUrl"
13 : size="large"
14 : />
15 :
16 : <div class="flex flex-col gap-0.5">
17 : <h3 class="font-medium">
18 : {{ $t('userSettings.name') }}
19 : </h3>
20 : <div class="text-muted-foreground">
21 : {{ userDisplayName || $t('userSettings.notSet') }}
22 : </div>
23 : </div>
24 :
25 : <div class="flex flex-col gap-0.5">
26 : <h3 class="font-medium">
27 : {{ $t('userSettings.email') }}
28 : </h3>
29 : <span class="text-muted-foreground">
30 : {{ userEmail }}
31 : </span>
32 : </div>
33 :
34 : <div class="flex flex-col gap-0.5">
35 : <h3 class="font-medium">
36 : {{ $t('userSettings.provider') }}
37 : </h3>
38 : <div class="flex items-center gap-1 text-muted-foreground">
39 : <i :class="providerIcon" />
40 : {{ providerName }}
41 : <Button
42 : v-if="isEmailProvider"
43 : :tooltip="$t('userSettings.updatePassword')"
44 : variant="muted-textonly"
45 : size="icon-sm"
46 : :aria-label="$t('userSettings.updatePassword')"
47 : @click="onUpdatePassword"
48 : >
49 : <i class="icon-[lucide--square-pen]" />
50 : </Button>
51 : </div>
52 : </div>
53 :
54 : <AppSpinner v-if="loading" class="mt-4 size-8" />
55 : <div v-else class="mt-4 flex flex-col gap-2">
56 : <div class="flex flex-wrap items-center gap-2">
57 : <Button class="w-32" variant="secondary" @click="handleSignOut">
58 : <i class="icon-[lucide--log-out]" />
59 : {{ $t('auth.signOut.signOut') }}
60 : </Button>
61 : <SignOutEverywhereButton />
62 : </div>
63 : <i18n-t
64 : v-if="!isApiKeyLogin"
65 : keypath="auth.deleteAccount.contactSupport"
66 : tag="p"
67 : class="text-sm text-muted-foreground"
68 : >
69 : <template #email>
70 : <a href="mailto:support@comfy.org" class="underline"
71 : >support@comfy.org</a
72 : >
73 : </template>
74 : </i18n-t>
75 : </div>
76 : </div>
77 :
78 : <!-- Login Section -->
79 : <div v-else class="flex flex-col gap-4">
80 : <p class="text-muted-foreground">
81 : {{ $t('auth.login.title') }}
82 : </p>
83 :
84 : <Button class="w-52" variant="primary" :loading @click="handleSignIn">
85 : <i class="icon-[lucide--user]" />
86 : {{ $t('auth.login.signInOrSignUp') }}
87 : </Button>
88 : </div>
89 : </div>
90 : </div>
91 : </template>
92 :
93 : <script setup lang="ts">
94 : import { useI18n } from 'vue-i18n'
95 : import { useRouter } from 'vue-router'
96 :
97 : import UserAvatar from '@comfyorg/design-system/common/UserAvatar'
98 : import Button from '@comfyorg/design-system/button/Button'
99 : import AppSpinner from '@/components/common/AppSpinner.vue'
100 : import { useCurrentUser } from '@/composables/auth/useCurrentUser'
101 : import SignOutEverywhereButton from '@/platform/auth/session/components/SignOutEverywhereButton.vue'
102 : import { useAuthDialogs } from '@/composables/auth/useAuthDialogs'
103 : import { useDialogService } from '@/services/dialogService'
104 :
105 1 : const { t } = useI18n()
106 1 : const router = useRouter()
107 1 : const dialogService = useDialogService()
108 1 : const { showUpdatePasswordDialog } = useAuthDialogs()
109 1 : const {
110 : loading,
111 : isLoggedIn,
112 : isApiKeyLogin,
113 : isEmailProvider,
114 : needsFirebaseSignIn,
115 : userDisplayName,
116 : userEmail,
117 : userPhotoUrl,
118 : providerName,
119 : providerIcon,
120 : handleSignOut,
121 : handleSignIn
122 : } = useCurrentUser()
123 0 : async function onUpdatePassword() {
124 0 : if (!needsFirebaseSignIn.value) {
125 0 : await showUpdatePasswordDialog()
126 0 : return
127 : }
128 : const confirmed = await dialogService.confirm({
129 : title: t('auth.reauthRequired.title'),
130 : message: t('auth.reauthRequired.message')
131 : })
132 0 : if (!confirmed) return
133 0 : const { href } = router.resolve({
134 : name: 'cloud-login',
135 : query: {
136 : switchAccount: 'true',
137 : previousFullPath: encodeURIComponent(router.currentRoute.value.fullPath)
138 : }
139 : })
140 0 : window.location.assign(href)
141 : }
142 : </script>
|