diff --git a/src/components/dialog/content/setting/UserPanel.vue b/src/components/dialog/content/setting/UserPanel.vue index afe950eca..9334c9363 100644 --- a/src/components/dialog/content/setting/UserPanel.vue +++ b/src/components/dialog/content/setting/UserPanel.vue @@ -5,10 +5,10 @@ -
+
@@ -18,7 +18,7 @@ {{ $t('userSettings.name') }}
- {{ user.displayName || $t('userSettings.notSet') }} + {{ userDisplayName || $t('userSettings.notSet') }}
@@ -26,8 +26,8 @@

{{ $t('userSettings.email') }}

- - {{ user.email }} + + {{ userEmail }}
@@ -67,27 +67,6 @@ /> - -
-
-

- {{ $t('auth.apiKey.title') }} -

-
- - {{ $t('auth.apiKey.label') }} -
-
- -
-

@@ -112,59 +91,22 @@ import Button from 'primevue/button' import Divider from 'primevue/divider' import ProgressSpinner from 'primevue/progressspinner' import TabPanel from 'primevue/tabpanel' -import { computed } from 'vue' import UserAvatar from '@/components/common/UserAvatar.vue' +import { useCurrentUser } from '@/composables/auth/useCurrentUser' import { useDialogService } from '@/services/dialogService' -import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore' -import { useCommandStore } from '@/stores/commandStore' -import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore' const dialogService = useDialogService() -const authStore = useFirebaseAuthStore() -const commandStore = useCommandStore() -const apiKeyStore = useApiKeyAuthStore() - -const user = computed(() => authStore.currentUser) -const loading = computed(() => authStore.loading) -const hasApiKey = computed(() => apiKeyStore.hasApiKey) - -const providerName = computed(() => { - const providerId = user.value?.providerData[0]?.providerId - if (providerId?.includes('google')) { - return 'Google' - } - if (providerId?.includes('github')) { - return 'GitHub' - } - return providerId -}) - -const providerIcon = computed(() => { - const providerId = user.value?.providerData[0]?.providerId - if (providerId?.includes('google')) { - return 'pi pi-google' - } - if (providerId?.includes('github')) { - return 'pi pi-github' - } - return 'pi pi-user' -}) - -const isEmailProvider = computed(() => { - const providerId = user.value?.providerData[0]?.providerId - return providerId === 'password' -}) - -const handleSignOut = async () => { - await commandStore.execute('Comfy.User.SignOut') -} - -const handleApiKeySignOut = async () => { - await apiKeyStore.clearStoredApiKey() -} - -const handleSignIn = async () => { - await commandStore.execute('Comfy.User.OpenSignInDialog') -} +const { + loading, + isLoggedIn, + isEmailProvider, + userDisplayName, + userEmail, + userPhotoUrl, + providerName, + providerIcon, + handleSignOut, + handleSignIn +} = useCurrentUser() diff --git a/src/components/topbar/CurrentUserButton.vue b/src/components/topbar/CurrentUserButton.vue index 902488a54..a7644143e 100644 --- a/src/components/topbar/CurrentUserButton.vue +++ b/src/components/topbar/CurrentUserButton.vue @@ -2,7 +2,7 @@