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