Skip to content

Instantly share code, notes, and snippets.

@vouill
vouill / auth.module.js
Created December 4, 2017 10:56
state object in module
const state = {
token: localStorage.getItem('user-token') || ''
status: '',
}
@vouill
vouill / login.js
Created December 4, 2017 10:53
login method vue
...
methods: {
login: function () {
const { username, password } = this
this.$store.dispatch(AUTH_REQUEST, { username, password }).then(() => {
this.$router.push('/')
})
}
}
...
@vouill
vouill / login.html
Last active December 4, 2017 11:24
Login template Vue
<template>
<div>
<form class="login" @submit.prevent="login">
<h1>Sign in</h1>
<label>User name</label>
<input required v-model="username" type="text" placeholder="Snoopy"/>
<label>Password</label>
<input required v-model="password" type="password" placeholder="Password"/>
<hr/>
<button type="submit">Login</button>