<!--
  - Copyright (c) 2022.
  - Author Peter Placzek (tada5hi)
  - For the full copyright and license information,
  - view the LICENSE file that was distributed with this source code.
  -->

<script>
import { mapActions } from 'vuex'

export default {
    async asyncData(ctx) {
        await ctx.store.dispatch('auth/triggerLogout');

        let query = {};
        if(ctx.route.query && ctx.route.query.hasOwnProperty('redirect')) {
            query.redirect = ctx.route.query.redirect;
        }

        await ctx.redirect({path: '/login', query});
    },
    mounted() {
        this.doLogout().then(r => r);
    },
    methods: {
        async doLogout () {
            await this.$store.dispatch('auth/triggerLogout');

            let query = {};
            if(this.$route.query && this.$route.query.hasOwnProperty('redirect')) {
                query.redirect = this.$route.query.redirect;
            }

            await this.$router.push({path: '/login', query});
        }
    }
}
</script>
<template>
    <div />
</template>
