From 1bd804693c45130dad141ddc24a2305935b0e11e Mon Sep 17 00:00:00 2001 From: 0xA455 Date: Tue, 5 Apr 2016 19:12:15 -0400 Subject: [PATCH] Fix exception with non-expiring session tokens. Session tokens generated by Parse with with "Expire inactive session" set to No leave the the expiresAt field undefined. This fixes the TypeError "Cannot read property 'iso' of undefined'" exception thrown when trying to use a session token with undefined expiresAt. --- src/Auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth.js b/src/Auth.js index 38959892..0e723a79 100644 --- a/src/Auth.js +++ b/src/Auth.js @@ -64,7 +64,7 @@ var getAuthForSessionToken = function({ config, sessionToken, installationId } = } var now = new Date(), - expiresAt = new Date(results[0].expiresAt.iso); + expiresAt = results[0].expiresAt ? new Date(results[0].expiresAt.iso) : undefined; if(expiresAt < now) { throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Session token is expired.');