diff --git a/lattice/src/services/useAuth.tsx b/lattice/src/services/useAuth.tsx index d6f5c7421..37a797a0e 100644 --- a/lattice/src/services/useAuth.tsx +++ b/lattice/src/services/useAuth.tsx @@ -56,26 +56,23 @@ 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 ( - res.data.startsWith( - "Trying to authenticate but authentication is off" - ) - ) { + if (res.status === 204) { + // 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(() => {