Add error page and login error redirection

This commit is contained in:
Chocobozzz
2019-04-01 11:49:54 +02:00
parent 5d8f1297b1
commit ceeb966edd
16 changed files with 187 additions and 30 deletions

View File

@@ -0,0 +1,23 @@
import { apolloProvider } from '@/vue-apollo';
import { CONFIG } from '@/graphql/config';
import { IConfig } from '@/types/config.model';
import { NavigationGuard } from 'vue-router';
import { ErrorRouteName } from '@/router/error';
import { ErrorCode } from '@/types/error-code.model';
export const beforeRegisterGuard: NavigationGuard = async function (to, from, next) {
const { data } = await apolloProvider.defaultClient.query({
query: CONFIG,
});
const config: IConfig = data.config;
if (config.registrationsOpen === false) {
return next({
name: ErrorRouteName.ERROR,
query: { code: ErrorCode.REGISTRATION_CLOSED },
});
}
return next();
};