Merged in feature/clear-cache (pull request #44)

Reset cache on logout, refactor logout
This commit is contained in:
Christian Cueni 2020-02-04 20:30:10 +00:00 committed by Ramon Wenger
commit d829d898b8
5 changed files with 34 additions and 38 deletions

View File

@ -14,7 +14,7 @@
this.$apollo.mutate({
mutation: LOGOUT_MUTATION,
}).then(({data}) => {
if (data.logout.success) { location.replace('/') }
if (data.logout.success) { location.replace('/logout') }
});
}
}

View File

@ -68,7 +68,7 @@
mutation: LOGOUT_MUTATION,
}).then(({data}) => {
if (data.logout.success) {
location.replace('/')
location.replace('/logout')
}
});
}

View File

@ -138,13 +138,22 @@ function redirectStudentsWithoutClass() {
}
router.beforeEach(async (to, from, next) => {
// handle logout
if (to.path === '/logout') {
privateApolloClient.resetStore();
next({name: 'login'});
return
}
if (unauthorizedAccess(to)) {
const redirectUrl = `/login?redirect=${to.path}`;
next(redirectUrl);
return
}
if (to.name !== 'noClass' && loginRequired(to) && await redirectStudentsWithoutClass()) {
router.push({name: 'noClass'})
next({name: 'noClass'})
return
}
next();

View File

@ -91,14 +91,8 @@ export default {
passwordInput: this.password
}
},
update(
store,
{
data: {
login
}
}
) {
fetchPolicy: 'no-cache',
}).then(({data: {login}}) => {
try {
if (login.success) {
const redirectUrl = that.$route.query.redirect ? that.$route.query.redirect : '/'
@ -118,7 +112,6 @@ export default {
console.warn(e);
that.loginError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
}
}
});
}
});
@ -128,7 +121,7 @@ export default {
this.password = '';
this.submitted = false;
this.$validator.reset();
}
},
},
data() {

View File

@ -144,14 +144,9 @@ export default {
licenseKeyInput: this.licenseKey,
}
},
update(
store,
{
data: {
registration: { success, errors }
}
}
) {
fetchPolicy: 'no-cache'
})
.then(({data: {registration: { success, errors }}}) => {
try {
if (success) {
window.location.href = '/registration/set-password/done/';
@ -170,7 +165,6 @@ export default {
console.warn(e);
that.registrationError = 'Es ist ein Fehler aufgetreten. Bitte versuchen Sie nochmals.';
}
}
});
}
});