Skip to content

Commit

Permalink
Fix imports for jwtDecode
Browse files Browse the repository at this point in the history
  • Loading branch information
0x46616c6b committed Jan 1, 2024
1 parent 120b561 commit 759a659
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/useAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { login as loginApi } from '../api/Auth'
import { useLocation, useNavigate } from 'react-router'
import decode from 'jwt-decode'
import { jwtDecode } from 'jwt-decode'

export type Roles = 'user' | 'admin'

Expand Down Expand Up @@ -45,7 +45,7 @@ export function AuthProvider({ children }: { children: ReactNode }): JSX.Element

let user: User
try {
user = decode(token) as User
user = jwtDecode(token) as User
} catch (error) {
setError(error as Error)
setLoadingInitial(false)
Expand All @@ -70,7 +70,7 @@ export function AuthProvider({ children }: { children: ReactNode }): JSX.Element
localStorage.setItem('token', response.token)
setToken(response.token)

const user = decode(response.token) as User
const user = jwtDecode(response.token) as User
setUser(user)
navigate('/')
})
Expand Down

0 comments on commit 759a659

Please sign in to comment.