feat: team access control

This commit is contained in:
2024-11-12 17:17:10 +00:00
parent f5250d5361
commit 2d4c81e15d
31 changed files with 410 additions and 161 deletions
+7 -6
View File
@@ -1,6 +1,5 @@
import { getCurrentServer } from "@/stores/app";
import authStore from "@/stores/auth";
import { QueryClient } from "@tanstack/react-query";
import { ofetch } from "ofetch";
const api = ofetch.create({
@@ -13,9 +12,13 @@ const api = ofetch.create({
// set server url
config.options.baseURL = server.url;
const authToken = authStore.getState().token;
if (authToken) {
config.options.headers.set("Authorization", `Bearer ${authToken}`);
const { token, teamId } = authStore.getState();
if (token) {
config.options.headers.set("Authorization", `Bearer ${token}`);
}
if (teamId) {
config.options.headers.set("X-Team-Id", teamId);
}
},
onResponseError: (error) => {
@@ -31,6 +34,4 @@ const api = ofetch.create({
},
});
export const queryClient = new QueryClient();
export default api;
+5
View File
@@ -0,0 +1,5 @@
import { QueryClient } from "@tanstack/react-query";
const queryClient = new QueryClient();
export default queryClient;