Skip to content

Commit 75d1c52

Browse files
authored
Merge pull request #913 from supabase-community/fix-refresh-check
Fix session expiration check
2 parents 926f9a0 + a3ac547 commit 75d1c52

File tree

1 file changed

+3
-2
lines changed
  • Auth/src/commonMain/kotlin/io/github/jan/supabase/auth

1 file changed

+3
-2
lines changed

Auth/src/commonMain/kotlin/io/github/jan/supabase/auth/AuthImpl.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ internal class AuthImpl(
423423
Auth.logger.d { "Session imported successfully." }
424424
return
425425
}
426-
if (session.expiresAt <= Clock.System.now()) {
427-
Auth.logger.d { "Session is expired. Handling expired session..." }
426+
val thresholdDate = session.expiresAt - session.expiresIn.seconds * (1 - SESSION_REFRESH_THRESHOLD)
427+
if (thresholdDate <= Clock.System.now()) {
428+
Auth.logger.d { "Session is under the threshold date. Refreshing session..." }
428429
tryImportingSession(
429430
{ handleExpiredSession(session, config.alwaysAutoRefresh) },
430431
{ importSession(session) }

0 commit comments

Comments
 (0)