Skip to content

Commit

Permalink
fix: removed localstorage key instead of setting it to null
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaYousefpourM committed Nov 26, 2023
1 parent fd3f7b9 commit 67ca6ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/providers/APIProvider/APIProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function APIProvider({children}) {
return

if (error.response.status === 401) {
localStorage['user'] = null
localStorage.removeItem('user')
setAccessTokenFromLocalStorage()
}
})
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/providers/config-provider/ConfigProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export function ConfigProvider({children}) {
const [refreshToken, setRefreshToken] = useState()

const setAccessTokenFromLocalStorage = useCallback(() => {
const lsItem = localStorage["user"]
const tokens = JSON.parse(lsItem !== 'null' ? lsItem : "{}")
const tokens = JSON.parse(localStorage["user"] ?? "{}")
if (tokens.access != null) {
setAccessToken(tokens.access)
if (tokens.refresh) {
Expand Down

0 comments on commit 67ca6ba

Please sign in to comment.