fix logout action
This commit is contained in:
@@ -13,12 +13,13 @@
|
||||
to="/editar/productos/importar"
|
||||
>Importar</NuxtLink
|
||||
>
|
||||
<NuxtLink to="/" @click="logout" >Cerrar sesión</NuxtLink>
|
||||
<NuxtLink to="/" @click="handleLogout" >Cerrar sesión</NuxtLink>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { mapActions } from 'pinia'
|
||||
export default {
|
||||
setup() {
|
||||
const auth = useAuthStore();
|
||||
@@ -35,8 +36,14 @@ export default {
|
||||
await this.checkIfCoopValidated()
|
||||
},
|
||||
methods: {
|
||||
async logout() {
|
||||
await this.auth.logout()
|
||||
...mapActions(useAuthStore, ['logout']),
|
||||
async handleLogout() {
|
||||
try {
|
||||
await this.logout()
|
||||
this.$router.push('/')
|
||||
} catch (error) {
|
||||
console.error('Error logging out:', error)
|
||||
}
|
||||
},
|
||||
async checkIfCoopValidated() {
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
Reference in New Issue
Block a user