2019-06-22 18:52:24 +03:00
|
|
|
import Vue from "vue";
|
|
|
|
import VueRouter, { RouteConfig } from "vue-router";
|
|
|
|
import Index from "./components/Index.vue";
|
|
|
|
import Login from "./components/Login.vue";
|
|
|
|
import LoginCallback from "./components/LoginCallback.vue";
|
2019-06-23 03:40:53 +03:00
|
|
|
import GuildConfigEditor from "./components/GuildConfigEditor.vue";
|
2019-06-22 18:52:24 +03:00
|
|
|
import Dashboard from "./components/Dashboard.vue";
|
|
|
|
import { authGuard, loginCallbackGuard } from "./auth";
|
|
|
|
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
|
|
|
|
const publicRoutes: RouteConfig[] = [
|
|
|
|
{ path: "/", component: Index },
|
|
|
|
{ path: "/login", component: Login },
|
|
|
|
{ path: "/login-callback", beforeEnter: loginCallbackGuard },
|
|
|
|
];
|
|
|
|
|
2019-06-23 03:40:53 +03:00
|
|
|
const authenticatedRoutes: RouteConfig[] = [
|
|
|
|
{ path: "/dashboard", component: Dashboard },
|
|
|
|
{ path: "/dashboard/guilds/:guildId/config", component: GuildConfigEditor },
|
|
|
|
];
|
2019-06-22 18:52:24 +03:00
|
|
|
|
|
|
|
authenticatedRoutes.forEach(route => {
|
|
|
|
route.beforeEnter = authGuard;
|
|
|
|
});
|
|
|
|
|
|
|
|
export const router = new VueRouter({
|
|
|
|
mode: "history",
|
|
|
|
routes: [...publicRoutes, ...authenticatedRoutes],
|
|
|
|
});
|