Skip to content

Commit a972c99

Browse files
authored
fix: refreshing tokens at the wrong time (#55)
* fix: refreshing tokens at the wrong time StoredSession.isValid was being calculated incorrectly, because by comparing to "1 minute ago", it means an access token which expires "30 seconds ago" is still valid for 30 seconds. Changing to plus 60 seconds eliminates this problem, and bakes in plenty of time for latency issues. In a future evolution I believe this value should be configurable. * configurable refresh tolerance * Revert "configurable refresh tolerance" This reverts commit 942acce.
1 parent fd020db commit a972c99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/GoTrue/Internal/SessionManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct StoredSession: Codable {
66
var expirationDate: Date
77

88
var isValid: Bool {
9-
expirationDate > Date().addingTimeInterval(-60)
9+
expirationDate > Date().addingTimeInterval(60)
1010
}
1111

1212
init(session: Session, expirationDate: Date? = nil) {

0 commit comments

Comments
 (0)