Line data Source code
1 1 : <template>
2 : <Button
3 0 : v-if="webSession.signedInUser"
4 : variant="destructive-textonly"
5 : :loading="signingOut"
6 : @click="signOutEverywhere"
7 : >
8 : {{ $t('auth.signOutEverywhere.action') }}
9 : </Button>
10 : </template>
11 :
12 : <script setup lang="ts">
13 : import { ref } from 'vue'
14 : import { useI18n } from 'vue-i18n'
15 :
16 : import Button from '@comfyorg/design-system/button/Button'
17 : import { useToast } from '@/components/ui/toast/toastStore'
18 : import { useAuthActions } from '@/composables/auth/useAuthActions'
19 : import {
20 : useCloudWebSessionStore,
21 : webSessionFailureMessage
22 : } from '@/platform/auth/session/cloudWebSessionStore'
23 :
24 0 : const { t } = useI18n()
25 0 : const { logout } = useAuthActions()
26 0 : const webSession = useCloudWebSessionStore()
27 0 : const toast = useToast()
28 0 : const signingOut = ref(false)
29 :
30 0 : async function revokeAllSessions(): Promise<boolean> {
31 0 : const result = await webSession.revokeAllSessions()
32 0 : if (result.status === 'error') {
33 0 : toast.error(t('auth.signOutEverywhere.failed'), {
34 : description: webSessionFailureMessage(result.code),
35 : duration: 8000
36 : })
37 0 : return false
38 : }
39 0 : toast.success(t('auth.signOutEverywhere.success'), {
40 : description: t('auth.signOutEverywhere.successDetail'),
41 : duration: 5000
42 : })
43 0 : return true
44 : }
45 :
46 0 : async function signOutEverywhere() {
47 0 : signingOut.value = true
48 0 : try {
49 0 : await logout({ beforeSignOut: revokeAllSessions })
50 : } finally {
51 0 : signingOut.value = false
52 : }
53 : }
54 : </script>
|