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

Switch from ajv to io-ts for config validation; validate configs on save in the API/dashboard; start work on creating io-ts schemas for all plugins

This commit is contained in:
Dragory 2019-07-11 12:23:57 +03:00
parent b230a73a6f
commit da114c0e60
14 changed files with 256 additions and 41 deletions

View file

@ -1,4 +1,4 @@
import { get, hasApiKey, post, setApiKey } from "../api";
import { get, post } from "../api";
import { ActionTree, Module } from "vuex";
import { AuthState, RootState } from "./types";
@ -16,13 +16,16 @@ export const AuthStore: Module<AuthState, RootState> = {
const storedKey = localStorage.getItem("apiKey");
if (storedKey) {
const result = await post("auth/validate-key", { key: storedKey });
if (result.valid) {
await dispatch("setApiKey", storedKey);
} else {
console.log("Unable to validate key, removing from localStorage");
localStorage.removeItem("apiKey");
}
try {
const result = await post("auth/validate-key", { key: storedKey });
if (result.valid) {
await dispatch("setApiKey", storedKey);
return;
}
} catch (e) {}
console.log("Unable to validate key, removing from localStorage");
localStorage.removeItem("apiKey");
}
commit("markInitialAuthLoaded");