This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/components/Home.vue

37 lines
761 B
Vue

<template>
<div>
<h3>Hiiiii</h3>
<span v-if="authenticated">Logged in
<button v-on:click="logout()" class="button">Logout</button>
</span>
</div>
</template>
<script>
import auth from '../auth'
import router from '../router'
export default {
name: "Home",
data() {
return {
authenticated: auth.user.authenticated
}
},
beforeMount() {
// Check if the user is already logged in, if so, redirect him to the homepage
if (!auth.user.authenticated) {
router.push({name: 'login'})
}
},
methods: {
logout () {
auth.logout()
}
},
}
</script>
<style scoped>
</style>