mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: team access control
This commit is contained in:
+7
-6
@@ -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;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { QueryClient } from "@tanstack/react-query";
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export default queryClient;
|
||||
Reference in New Issue
Block a user