Handle native GraphQLErrors

This commit is contained in:
Christian Cueni 2020-03-09 14:53:00 +01:00
parent b2d8c374c0
commit 59d5376f60
2 changed files with 21 additions and 20 deletions

View File

@ -103,9 +103,15 @@ export default {
if (localLogin.success) { if (localLogin.success) {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/' const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
that.$router.push(redirectUrl); that.$router.push(redirectUrl);
} else { }
const firstError = localLogin.errors[0]; } catch (e) {
switch (firstError.field) { console.warn(e);
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
}
}
}).catch(error => {
const firstError = error.graphQLErrors[0];
switch (firstError.message) {
case 'invalid_credentials': case 'invalid_credentials':
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.'; that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
break; break;
@ -113,12 +119,6 @@ export default {
that.loginError = 'Ihre Lizenz ist nicht mehr aktiv.'; that.loginError = 'Ihre Lizenz ist nicht mehr aktiv.';
break; break;
} }
}
} catch (e) {
console.warn(e);
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
}
}
}); });
} }
}); });

View File

@ -95,9 +95,16 @@ export default {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'; const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/';
that.$router.push(redirectUrl); that.$router.push(redirectUrl);
} }
} else { }
const firstError = login.errors[0]; } catch (e) {
switch (firstError.field) { console.warn(e);
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
}
}
})
.catch(errors => {
const firstError = errors.graphQLErrors[0];
switch (firstError.message) {
case 'invalid_credentials': case 'invalid_credentials':
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.'; that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
break; break;
@ -105,12 +112,6 @@ export default {
this.$router.push({name: 'licenseActivation'}) this.$router.push({name: 'licenseActivation'})
break; break;
} }
}
} catch (e) {
console.warn(e);
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
}
}
}); });
}, },
resetForm() { resetForm() {