Skip to content

Commit

Permalink
fix(lib-classifier): refresh expired bearer tokens
Browse files Browse the repository at this point in the history
Fix `usePanoptesAuth` hook to refresh expired bearer tokens in the classifier. Fixes a bug where Quick Talk stops working once your bearer token expires.
  • Loading branch information
eatyourgreens committed Jan 8, 2025
1 parent fd585a1 commit 9000e48
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/lib-classifier/src/hooks/usePanoptesAuth.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { useEffect, useState } from 'react'
import { useState } from 'react'

import { getBearerToken } from '@store/utils'

export default function usePanoptesAuth({ authClient, userID }) {
export default function usePanoptesAuth({ authClient }) {
const [authorization, setAuthorization] = useState()

async function checkAuth() {
const token = await getBearerToken(authClient)
setAuthorization(token)
if (token !== authorization) {
setAuthorization(token)
}
}

useEffect(function onUserChange() {
checkAuth()
}, [authClient, userID])
checkAuth()

return authorization
}

0 comments on commit 9000e48

Please sign in to comment.