From adcc21eee1c5e284b2ccfe7a0a1ef78d88339653 Mon Sep 17 00:00:00 2001
From: Leonardo Christino <leomilho@gmail.com>
Date: Tue, 24 Oct 2023 16:59:35 +0200
Subject: [PATCH] chore(auth): update useAuth

standardize fetch with cookie-based auth call
---
 apps/web/src/app/app.tsx                  | 19 ++-----------------
 apps/web/src/components/navbar/navbar.tsx |  2 +-
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/apps/web/src/app/app.tsx b/apps/web/src/app/app.tsx
index 919cd2c60..70e28b387 100644
--- a/apps/web/src/app/app.tsx
+++ b/apps/web/src/app/app.tsx
@@ -70,21 +70,6 @@ export function App(props: App) {
       Broker.instance().subscribe((data: LinkPredictionInstance[]) => dispatch(setMLResult({ type: mlType, result: data })), mlType);
     });
 
-    const domain = import.meta.env.BACKEND_URL;
-    const useruri = import.meta.env.BACKEND_USER;
-    fetch(`${domain}${useruri}/headers`, {
-      method: 'GET',
-      redirect: 'follow',
-    });
-    fetch(`${domain}${useruri}/headers`, {
-      method: 'GET',
-      credentials: 'include',
-      redirect: 'follow',
-      headers: {
-        Authorization: `Bearer ${auth.accessToken}`,
-      },
-    });
-
     return () => {
       Broker.instance().unSubscribeAll('schema_result');
       Broker.instance().unSubscribeAll('query_result');
@@ -96,8 +81,8 @@ export function App(props: App) {
 
   useEffect(() => {
     // New active database
-    if (auth.accessToken && session.currentDatabase) {
-      ws.current.useToken(auth.accessToken).connect(() => {
+    if (auth.jwt && session.currentDatabase) {
+      ws.current.useToken(auth.jwt).connect(() => {
         api_schema.RequestSchema(session.currentDatabase);
       });
     }
diff --git a/apps/web/src/components/navbar/navbar.tsx b/apps/web/src/components/navbar/navbar.tsx
index 74d3efd98..0042a5619 100644
--- a/apps/web/src/components/navbar/navbar.tsx
+++ b/apps/web/src/components/navbar/navbar.tsx
@@ -81,7 +81,7 @@ export const Navbar = (props: NavbarComponentProps) => {
         </a>
         <SearchBar />
         <div className="dropdown">
-          <label tabIndex={0} className="s-1">
+          <label tabIndex={0} className="btn s-1">
             Vis
           </label>
           <ul tabIndex={0} className="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52">
-- 
GitLab