Use auth store
This commit is contained in:
parent
48bfbe80fe
commit
e22f774385
@ -17,17 +17,18 @@
|
||||
</template>
|
||||
|
||||
<v-list>
|
||||
<client-only>
|
||||
<v-list-item v-if="isAuthenticated" to="/notes">
|
||||
My notes
|
||||
</v-list-item>
|
||||
<v-list-item v-if="isAuthenticated" @click="logout">
|
||||
Logout
|
||||
</v-list-item>
|
||||
<v-list-item v-else>
|
||||
<v-btn to="/account" text rounded>Account</v-btn>
|
||||
</v-list-item>
|
||||
</client-only>
|
||||
<v-list-item
|
||||
v-if="loggedIn && !$route.path.includes('/notes')"
|
||||
to="/notes"
|
||||
>
|
||||
My notes
|
||||
</v-list-item>
|
||||
<v-list-item v-if="loggedIn" @click="logout">
|
||||
Logout
|
||||
</v-list-item>
|
||||
<v-list-item v-else>
|
||||
<v-btn to="/account" text rounded>Account</v-btn>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-app-bar>
|
||||
@ -35,7 +36,7 @@
|
||||
|
||||
<script>
|
||||
import { mdiDotsVertical, mdiBrightness5, mdiBrightness2 } from '@mdi/js'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'Navbar',
|
||||
@ -45,7 +46,7 @@ export default {
|
||||
mdiBrightness2,
|
||||
}),
|
||||
computed: {
|
||||
...mapGetters(['isAuthenticated', 'loggedInUser']),
|
||||
...mapState('auth', ['loggedIn']),
|
||||
},
|
||||
methods: {
|
||||
async logout() {
|
||||
|
||||
@ -4,12 +4,4 @@ export const mutations = {}
|
||||
|
||||
export const actions = {}
|
||||
|
||||
export const getters = {
|
||||
isAuthenticated(state) {
|
||||
return state.auth.loggedIn
|
||||
},
|
||||
|
||||
loggedInUser(state) {
|
||||
return state.auth.user
|
||||
},
|
||||
}
|
||||
export const getters = {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user