I'm new on laravel 5.8 and Vue and I'm using veeValidate and a basic FORM to login having:
method="POST" action="/login" and values: email, password and _token for csrf_token
and a button for submission like that:
<v-btn>@click="validate">Login</v-btn>
When user click on button the vue method validate is invoked:
methods: {
validate() {
this.$validator.validateAll().then((result) => {
if (result) {
//Manually submit form if not errors
document.getElementById("login_form").submit();
}
})
},
}
This method run the veeValidate validator and if true then the form is submitted (POST to the action path). On error it update the frontend errors alert (ie. missing data or password too short).
The route redirect the POST request to the Laravel's Controller Auth/LoginController@login which has the protected $redirectTo = '/welcome';
$redirectTo is the landing page in case of no errors (Login). But if validator fail it redirect to the form page which is reloaded with no alerts.
I like the simple flow but I would like to show the failed backend reasons (IE: any feedback or login attempts);
How can I get the LoginController@login bad response to show a message into the vue component?