Now use vuex to manage state for authentication

This commit is contained in:
Eliot Berriot 2017-12-23 17:47:13 +01:00
parent df94ae37bf
commit b5ce65fc3e
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
14 changed files with 137 additions and 179 deletions

View file

@ -3,8 +3,8 @@
<div class="ui vertical stripe segment">
<div class="ui small text container">
<h2>Are you sure you want to log out?</h2>
<p>You are currently logged in as {{ auth.user.username }}</p>
<button class="ui button" @click="logout">Yes, log me out!</button>
<p>You are currently logged in as {{ $store.state.auth.username }}</p>
<button class="ui button" @click="$store.dispatch('auth/logout')">Yes, log me out!</button>
</form>
</div>
</div>
@ -12,23 +12,8 @@
</template>
<script>
import auth from '@/auth'
export default {
name: 'logout',
data () {
return {
// We need to initialize the component with any
// properties that will be used in it
auth: auth
}
},
methods: {
logout () {
auth.logout()
this.$router.push({name: 'index'})
}
}
name: 'logout'
}
</script>