mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
dashboard: auth fixes, guild listing, config editing
This commit is contained in:
parent
1dae3019c4
commit
7bda2b1763
14 changed files with 200 additions and 42 deletions
|
@ -16,11 +16,11 @@ export const AuthStore: Module<AuthState, RootState> = {
|
|||
|
||||
const storedKey = localStorage.getItem("apiKey");
|
||||
if (storedKey) {
|
||||
console.log("key?", storedKey);
|
||||
const result = await post("auth/validate-key", { key: storedKey });
|
||||
if (result.isValid) {
|
||||
if (result.valid) {
|
||||
await dispatch("setApiKey", storedKey);
|
||||
} else {
|
||||
console.log("Unable to validate key, removing from localStorage");
|
||||
localStorage.removeItem("apiKey");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { get } from "../api";
|
||||
import { get, post } from "../api";
|
||||
import { Module } from "vuex";
|
||||
import { GuildState, LoadStatus, RootState } from "./types";
|
||||
|
||||
|
@ -19,6 +19,15 @@ export const GuildStore: Module<GuildState, RootState> = {
|
|||
const availableGuilds = await get("guilds/available");
|
||||
commit("setAvailableGuilds", availableGuilds);
|
||||
},
|
||||
|
||||
async loadConfig({ commit }, guildId) {
|
||||
const result = await get(`guilds/${guildId}/config`);
|
||||
commit("setConfig", { guildId, config: result.config });
|
||||
},
|
||||
|
||||
async saveConfig({ commit }, { guildId, config }) {
|
||||
await post(`guilds/${guildId}/config`, { config });
|
||||
},
|
||||
},
|
||||
|
||||
mutations: {
|
||||
|
@ -30,5 +39,9 @@ export const GuildStore: Module<GuildState, RootState> = {
|
|||
state.available = guilds;
|
||||
state.availableGuildsLoadStatus = LoadStatus.Done;
|
||||
},
|
||||
|
||||
setConfig(state: GuildState, { guildId, config }) {
|
||||
state.configs[guildId] = config;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue