REST login/logout is working
This commit is contained in:
@ -8,7 +8,8 @@
|
||||
type="text"
|
||||
placeholder="Email" name="name"
|
||||
v-model="mail"
|
||||
@keyup.enter="login"/>
|
||||
@keyup.enter="login"
|
||||
/>
|
||||
<input
|
||||
id="edit-pass"
|
||||
class="form-text"
|
||||
@ -41,12 +42,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['User']),
|
||||
// ...mapState({
|
||||
// isloggedin: state => state.user.isloggedin,
|
||||
// username: state => state.user.username,
|
||||
// token: state => state.user.token
|
||||
// })
|
||||
...mapState(['User'])
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
@ -0,0 +1,31 @@
|
||||
<template lang="html">
|
||||
<UserTools v-if="token" />
|
||||
<Login v-else />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
import Login from 'vuejs/components/User/Login'
|
||||
import UserTools from 'vuejs/components/User/UserTools'
|
||||
|
||||
export default {
|
||||
// data () {
|
||||
// return {}
|
||||
// },
|
||||
computed: {
|
||||
...mapState({
|
||||
token: state => state.User.token
|
||||
})
|
||||
},
|
||||
components: {
|
||||
Login,
|
||||
UserTools
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,38 @@
|
||||
<template lang="html">
|
||||
<div id="user-tools">
|
||||
<h4>{{ mail }}</h4>
|
||||
<a href="/user/logout"
|
||||
@click.prevent="onLogout()"
|
||||
>
|
||||
logout
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
export default {
|
||||
// data () {
|
||||
// return {
|
||||
// mail: "Hello User!"
|
||||
// }
|
||||
// },
|
||||
computed: {
|
||||
...mapState({
|
||||
mail: state => state.User.mail
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
userLogout: 'User/userLogout'
|
||||
}),
|
||||
onLogout () {
|
||||
this.userLogout()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
Reference in New Issue
Block a user