Revert "fix(studio): delegate check for expired token to gotrue" (#41268)

Revert "fix(studio): delegate check for expired token to gotrue (#41010)"

This reverts commit 730decf561.
This commit is contained in:
Charis authored and GitHub committed 2025-12-11 09:38:46 -05:00
1 parent 91025ec817
commit 16cdd025b7
1 file changed
+16 -10
+16 -10
View File
@@ -159,21 +159,27 @@ gotrueClient.onAuthStateChange((event, session) => {
})
/**
* Gets a current access token.
*
* Calls getSession, which will refresh the token if needed.
* Grabs the currently available access token, or calls getSession.
*/
export async function getAccessToken() {
// ignore if server-side
if (typeof window === 'undefined') return undefined
const {
data: { session },
error,
} = await gotrueClient.getSession()
if (error) {
throw error
const aboutToExpire = currentSession?.expires_at
? currentSession.expires_at - Math.ceil(Date.now() / 1000) < 30
: false
if (!currentSession || aboutToExpire) {
const {
data: { session },
error,
} = await gotrueClient.getSession()
if (error) {
throw error
}
return session?.access_token
}
return session?.access_token
return currentSession.access_token
}