Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/components/Login.vue
Show All 11 Lines | <div class="text-center form-wrapper"> | ||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> | <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> | ||||
<br><br><router-link :to="{ name: 'password-reset' }">Forgot password?</router-link> | <br><br><router-link :to="{ name: 'password-reset' }">Forgot password?</router-link> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import store from '../js/store' | |||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
email: '', | email: '', | ||||
password: '', | password: '', | ||||
loginError: false, | loginError: false, | ||||
} | } | ||||
}, | }, | ||||
methods: { | methods: { | ||||
submitLogin() { | submitLogin() { | ||||
this.loginError = false; | this.loginError = false; | ||||
axios.post('/api/auth/login', { | axios.post('/api/auth/login', { | ||||
email: this.email, | email: this.email, | ||||
password: this.password | password: this.password | ||||
}).then(response => { | }).then(response => { | ||||
// login user, store the token and redirect to dashboard | // login user and redirect to dashboard | ||||
store.commit('loginUser') | this.$root.loginUser(response.data.access_token) | ||||
localStorage.setItem('token', response.data.access_token) | |||||
this.$router.push({ name: 'dashboard' }) | |||||
}).catch(error => { | }).catch(error => { | ||||
this.loginError = true | this.loginError = true | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> | ||||
Show All 39 Lines |