3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Dashboard work. Move configs to DB. Some script reorganization. Add nodemon configs.

This commit is contained in:
Dragory 2019-06-22 18:52:24 +03:00
parent 168d82a966
commit 2adc5af8d7
39 changed files with 8441 additions and 2915 deletions

15
dashboard/src/auth.ts Normal file
View file

@ -0,0 +1,15 @@
import { NavigationGuard } from "vue-router";
import { RootStore } from "./store";
export const authGuard: NavigationGuard = async (to, from, next) => {
if (RootStore.state.auth.apiKey) return next(); // We have an API key -> authenticated
if (RootStore.state.auth.loadedInitialAuth) return next("/login"); // No API key and initial auth data was already loaded -> not authenticated
await RootStore.dispatch("auth/loadInitialAuth"); // Initial auth data wasn't loaded yet (per above check) -> load it now
if (RootStore.state.auth.apiKey) return next();
next("/login"); // Still no API key -> not authenticated
};
export const loginCallbackGuard: NavigationGuard = async (to, from, next) => {
await RootStore.dispatch("auth/setApiKey", to.query.apiKey);
next("/dashboard");
};