From 9086587e065af30b4668f393b5fd6cea3b3dd267 Mon Sep 17 00:00:00 2001 From: Hoang Pham Date: Mon, 20 Dec 2021 12:19:56 -0600 Subject: [PATCH 1/2] Changed how the UI processes /auth to turn on/off authentication --- lattice/src/services/useAuth.tsx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lattice/src/services/useAuth.tsx b/lattice/src/services/useAuth.tsx index d6f5c7421..224059ef5 100644 --- a/lattice/src/services/useAuth.tsx +++ b/lattice/src/services/useAuth.tsx @@ -56,26 +56,26 @@ function useProvideAuth() { pilosa.get .auth() .then((res) => { - // User is authenticated - if (res.data === "OK") { - setAuthOn(true); - setIsAuthenticated(true); - - // get userinfo - userinfo(); - } - // Auth is off - else if ( + if (res.status === 204) { + // Authentication is off res.data.startsWith( "Trying to authenticate but authentication is off" - ) - ) { + ); setAuthOn(false); - } - // User not authenticated - else { + } else { + // Turn on Authentication setAuthOn(true); - setIsAuthenticated(false); + + if (res.data === "OK") { + // User is authenticated + setIsAuthenticated(true); + + // get userinfo + userinfo(); + } else { + // User not authenticated + setIsAuthenticated(false); + } } }) .finally(() => { From 7dc9df425d8a76ff3cd4a41c46e02963224cd26d Mon Sep 17 00:00:00 2001 From: Hoang Pham Date: Mon, 20 Dec 2021 12:23:55 -0600 Subject: [PATCH 2/2] UI - removed unnecessary code --- lattice/src/services/useAuth.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/lattice/src/services/useAuth.tsx b/lattice/src/services/useAuth.tsx index 224059ef5..37a797a0e 100644 --- a/lattice/src/services/useAuth.tsx +++ b/lattice/src/services/useAuth.tsx @@ -58,9 +58,6 @@ function useProvideAuth() { .then((res) => { if (res.status === 204) { // Authentication is off - res.data.startsWith( - "Trying to authenticate but authentication is off" - ); setAuthOn(false); } else { // Turn on Authentication