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,22 +103,22 @@ export default {
if (localLogin.success) {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
that.$router.push(redirectUrl);
} else {
const firstError = localLogin.errors[0];
switch (firstError.field) {
case 'invalid_credentials':
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
break;
case 'license_inactive':
that.loginError = 'Ihre Lizenz ist nicht mehr aktiv.';
break;
}
}
} catch (e) {
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':
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
break;
case 'license_inactive':
that.loginError = 'Ihre Lizenz ist nicht mehr aktiv.';
break;
}
});
}
});

View File

@ -95,22 +95,23 @@ export default {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/';
that.$router.push(redirectUrl);
}
} else {
const firstError = login.errors[0];
switch (firstError.field) {
case 'invalid_credentials':
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
break;
case 'no_valid_license':
this.$router.push({name: 'licenseActivation'})
break;
}
}
} catch (e) {
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':
that.loginError = 'Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.';
break;
case 'no_valid_license':
this.$router.push({name: 'licenseActivation'})
break;
}
});
},
resetForm() {