Created
May 30, 2018 20:49
-
-
Save michalbujalski/f311b260fd3a608be709c540bff72e19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<form @submit.prevent="onSubmit" > | |
<input v-model="login" type="text"/> | |
<input v-model="password" type="password"/> | |
<input type="submit" value="Login"/> | |
</form> | |
</template> | |
<script> | |
import {mapGetters} from 'vuex' | |
export default { | |
computed: { | |
...mapGetters(['user']), | |
nextRoute () { | |
return this.$route.query.redirect || '/' | |
} | |
}, | |
data () { | |
return { | |
login: '', | |
password: '' | |
} | |
}, | |
watch: { | |
user (auth) { | |
if(!!auth){ | |
this.$router.replace(this.nextRoute) | |
} | |
} | |
}, | |
methods: { | |
async onSubmit () { | |
const auth = await this.$auth.login(this.login, this.password) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment