Open igeligel opened 5 years ago
I'll take a look at this
The problem with this one is that the original code never resolves or rejects the promise in case of errors. This is by itself incorrect. When converting this to async/await the promise will always be either resolved or rejected. This results in unwanted redirection to home in case of an error (because the error is not propagated, hence the promise gets resolved). This can be fixed by re-throwing the error from the catch block and swallowing it here like this:
onSubmit(email, password) {
this.$store
.dispatch(LOGIN, { email, password })
.then(() => this.$router.push({ name: "home" }))
.catch(e => { /* the exception was already handled */});
}
or by returning the data and checking inside the then
for an error to know whether to redirect or not.
Issue Summary:
In the auth.module.js here you have got some code like:
Those promise calls could be simpliefied with async and await calls.
Resources:
Acceptance Criteria:
.then(...
or.catch(...
block or any promise like structureMain issue is here #5