Skip to content

Commit

Permalink
refactor(useAuthorization.ts): remove unnecessary setLoading state va…
Browse files Browse the repository at this point in the history
…riable and setLoading calls

The setLoading state variable and its corresponding calls to setLoading(false) are no longer necessary as they are not being used. Removing them simplifies the code and improves readability.
  • Loading branch information
ktun95 committed Feb 8, 2024
1 parent 65eb533 commit c090069
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/auth/src/useAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ type useAuthorizationProperties = { entries: Array<string> }
*/
const useAuthorization = ({ entries }: useAuthorizationProperties) => {
// Fetch the user information using the useLogto hook
const { fetchUserInfo, isAuthenticated } = useLogto()
const { fetchUserInfo, isAuthenticated, isLoading } = useLogto()

// Initialize state variables
const [isAuthorized, setAuthorization] = useState<boolean>(false)
const [isLoading, setLoading] = useState<boolean>(true)
// const [isLoading, setLoading] = useState<boolean>(true)
const [user, setUser] = useState<UserWithRoles>()

useEffect(() => {
// Function to check user authorization
const authCheck = async (records: Array<string>) => {
if (!isAuthenticated) {
setLoading(false)
// setLoading(false)
return
}
// Fetch the user information and cast it to UserWithRoles type
Expand All @@ -33,7 +32,7 @@ const useAuthorization = ({ entries }: useAuthorizationProperties) => {
setUser(authUser)
}
// Set the loading state to false once the authorization check is completed
setLoading(false)
// setLoading(false)
}
// Perform the authorization check when the entries array changes
authCheck(entries)
Expand Down

0 comments on commit c090069

Please sign in to comment.