Fix license verification flow

This commit is contained in:
Christian Cueni 2020-02-18 13:32:17 +01:00
parent 677d8dbf44
commit 26a342c5a5
5 changed files with 20 additions and 5 deletions

View File

@ -1,6 +1,7 @@
mutation Login($input: LoginInput!) { mutation Login($input: LoginInput!) {
login(input: $input) { login(input: $input) {
success success
message
errors { errors {
field field
} }

View File

@ -153,12 +153,13 @@ router.beforeEach(async (to, from, next) => {
next({name: 'login'}); next({name: 'login'});
return; return;
} }
getCookieValue('loginStatus')
if (unauthorizedAccess(to)) { if (unauthorizedAccess(to)) {
const redirectUrl = `/login?redirect=${to.path}`; const redirectUrl = `/login?redirect=${to.path}`;
next(redirectUrl); next(redirectUrl);
return; return;
} }
if ((to.name !== 'noClass' && to.name !== 'licenseActivation') && loginRequired(to) && await redirectStudentsWithoutClass()) { if ((to.name !== 'noClass' && to.name !== 'licenseActivation') && loginRequired(to) && await redirectStudentsWithoutClass()) {
next({name: 'noClass'}) next({name: 'noClass'})
return; return;

View File

@ -50,7 +50,13 @@ export default {
this.loading = false; this.loading = false;
if (data.registration.success) { if (data.registration.success) {
this.keyValid = true; this.keyValid = true;
this.$router.push('/');
if (data.registration.message === 'no_valid_license') {
this.$router.push({name: 'licenseActivation'});
} else {
this.$router.push('/');
}
} else { } else {
switch (data.registration.errors[0].field) { switch (data.registration.errors[0].field) {
case 'invalid_key': case 'invalid_key':

View File

@ -101,7 +101,10 @@ export default {
coupon: '', coupon: '',
couponErrors: [], couponErrors: [],
loginError: '', loginError: '',
submitted: false submitted: false,
me: {
email: ''
}
}; };
}, },

View File

@ -90,8 +90,12 @@ export default {
) { ) {
try { try {
if (login.success) { if (login.success) {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'; if (login.message === 'no_valid_license') {
that.$router.push(redirectUrl); that.$router.push({name: 'licenseActivation'})
} else {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/';
that.$router.push(redirectUrl);
}
} else { } else {
const firstError = login.errors[0]; const firstError = login.errors[0];
switch (firstError.field) { switch (firstError.field) {