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!) {
login(input: $input) {
success
message
errors {
field
}

View File

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

View File

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

View File

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

View File

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