From e356716eeeb1619be81d51958a40555cedbe5965 Mon Sep 17 00:00:00 2001 From: leandrofars Date: Wed, 30 Oct 2024 08:29:13 -0300 Subject: [PATCH] fix(frontend): sign out errors --- frontend/src/contexts/auth-context.js | 2 ++ frontend/src/pages/devices.js | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/frontend/src/contexts/auth-context.js b/frontend/src/contexts/auth-context.js index a35e9d4..8400f9e 100644 --- a/frontend/src/contexts/auth-context.js +++ b/frontend/src/contexts/auth-context.js @@ -211,6 +211,8 @@ export const AuthProvider = (props) => { }; const signOut = () => { + router.push("/auth/login") + localStorage.removeItem("token") dispatch({ type: HANDLERS.SIGN_OUT }); diff --git a/frontend/src/pages/devices.js b/frontend/src/pages/devices.js index 1f91311..48183ee 100644 --- a/frontend/src/pages/devices.js +++ b/frontend/src/pages/devices.js @@ -172,8 +172,7 @@ const Page = () => { } const getDeviceProtocol = (order) => { - console.log("order:", order) - if (order.Cwmp == 2) { + if (order.Cwmp != null) { return "cwmp" } else { return "usp" @@ -204,15 +203,10 @@ const Page = () => { useEffect(() => { getColumns() setLoading(true) - if (auth.user.token) { - console.log("auth.user.token =", auth.user.token) - } else { - auth.user.token = localStorage.getItem("token") - } var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); - myHeaders.append("Authorization", auth.user.token); + myHeaders.append("Authorization", localStorage.getItem("token")); var requestOptions = { method: 'GET', @@ -293,8 +287,9 @@ const Page = () => { console.log("set alias result:", content) setShowSetDeviceAlias(false) setDeviceAlias(null) - orders[deviceToBeChanged].Alias = alias + devices[deviceToBeChanged].Alias = alias setDeviceToBeChanged(null) + setDevices([...devices]) } // .then(response => { // if (response.status === 401) { @@ -415,7 +410,7 @@ const Page = () => { <> - Oktopus | TR-369 + Oktopus | Controller @@ -651,7 +646,7 @@ const Page = () => { } - {/* + - + {/* }