mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor(editor): Migrate SignoutView.vue
to composition API (#10720)
This commit is contained in:
parent
297b668f32
commit
d9473a5f9d
|
@ -1,33 +1,27 @@
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { VIEWS } from '@/constants';
|
import { VIEWS } from '@/constants';
|
||||||
import { mapStores } from 'pinia';
|
|
||||||
import { useUsersStore } from '@/stores/users.store';
|
import { useUsersStore } from '@/stores/users.store';
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { useToast } from '@/composables/useToast';
|
import { useToast } from '@/composables/useToast';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { useI18n } from '@/composables/useI18n';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
const usersStore = useUsersStore();
|
||||||
name: 'SignoutView',
|
const toast = useToast();
|
||||||
setup() {
|
const router = useRouter();
|
||||||
return {
|
const i18n = useI18n();
|
||||||
...useToast(),
|
|
||||||
};
|
const logout = async () => {
|
||||||
},
|
try {
|
||||||
computed: {
|
await usersStore.logout();
|
||||||
...mapStores(useUsersStore),
|
window.location.href = router.resolve({ name: VIEWS.SIGNIN }).href;
|
||||||
},
|
} catch (e) {
|
||||||
mounted() {
|
toast.showError(e, i18n.baseText('auth.signout.error'));
|
||||||
void this.logout();
|
}
|
||||||
},
|
};
|
||||||
methods: {
|
|
||||||
async logout() {
|
onMounted(() => {
|
||||||
try {
|
void logout();
|
||||||
await this.usersStore.logout();
|
|
||||||
window.location.href = this.$router.resolve({ name: VIEWS.SIGNIN }).href;
|
|
||||||
} catch (e) {
|
|
||||||
this.showError(e, this.$locale.baseText('auth.signout.error'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue