Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import { NavigationGuard } from 'vue-router';
|
||||
import { UserRouteName } from '@/router/user';
|
||||
import { LoginErrorCode } from '@/types/login-error-code.model';
|
||||
import { AUTH_ACCESS_TOKEN } from '@/constants';
|
||||
import { NavigationGuard } from "vue-router";
|
||||
import { UserRouteName } from "@/router/user";
|
||||
import { LoginErrorCode } from "@/types/login-error-code.model";
|
||||
import { AUTH_ACCESS_TOKEN } from "@/constants";
|
||||
|
||||
export const authGuardIfNeeded: NavigationGuard = async function (to, from, next) {
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const authGuardIfNeeded: NavigationGuard = async (to, from, next) => {
|
||||
if (to.meta.requiredAuth !== true) return next();
|
||||
|
||||
// We can't use "currentUser" from apollo here because we may not have loaded the user from the local storage yet
|
||||
// We can't use "currentUser" from apollo here
|
||||
// because we may not have loaded the user from the local storage yet
|
||||
if (!localStorage.getItem(AUTH_ACCESS_TOKEN)) {
|
||||
return next({
|
||||
name: UserRouteName.LOGIN,
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
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';
|
||||
import { NavigationGuard } from "vue-router";
|
||||
import { CONFIG } from "../../graphql/config";
|
||||
import { ErrorCode } from "../../types/error-code.model";
|
||||
import apolloProvider from "../../vue-apollo";
|
||||
|
||||
export const beforeRegisterGuard: NavigationGuard = async function (to, from, next) {
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const beforeRegisterGuard: NavigationGuard = async (to, from, next) => {
|
||||
const { data } = await apolloProvider.defaultClient.query({
|
||||
query: CONFIG,
|
||||
});
|
||||
|
||||
const config: IConfig = data.config;
|
||||
const { config } = data;
|
||||
|
||||
if (!config.registrationsOpen && !config.registrationsWhitelist) {
|
||||
return next({
|
||||
name: ErrorRouteName.ERROR,
|
||||
name: "Error",
|
||||
query: { code: ErrorCode.REGISTRATION_CLOSED },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user