From f84171de8357dbdcd426355f9c37338254037ac9 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 21 Jan 2020 23:45:54 +0000 Subject: [PATCH] Confirm user logout --- webclient/src/App.js | 12 +++++++++--- webclient/src/LoginSignup.js | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/webclient/src/App.js b/webclient/src/App.js index dfb495a..bc79972 100644 --- a/webclient/src/App.js +++ b/webclient/src/App.js @@ -17,6 +17,7 @@ function App() { const [token, setToken] = useState(localStorage.getItem('token', '')); const [user, setUser] = useState(JSON.parse(localStorage.getItem('user', 'false'))); const [refreshCount, refreshUser] = useReducer(x => x + 1, 0); + const [yousure, setYousure] = useState(false); function setTokenCache(x) { setToken(x); @@ -40,8 +41,13 @@ function App() { }, [token, refreshCount]); function logout() { - setTokenCache(''); - setUserCache(false); + if (yousure) { + setTokenCache(''); + setUserCache(false); + setYousure(false); + } else { + setYousure(true); + } } return ( @@ -110,7 +116,7 @@ function App() { {user && { setLoading(true); - requester('/rest-auth/login/', 'POST', '', input) + const data = { ...input, username: input.username.toLowerCase() }; + requester('/rest-auth/login/', 'POST', '', data) .then(res => { setError({}); props.setTokenCache(res.key);