Skip to content

Instantly share code, notes, and snippets.

@michalbujalski
Created May 30, 2018 20:49
Show Gist options
  • Save michalbujalski/f311b260fd3a608be709c540bff72e19 to your computer and use it in GitHub Desktop.
Save michalbujalski/f311b260fd3a608be709c540bff72e19 to your computer and use it in GitHub Desktop.
<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