Skip to content

Commit

Permalink
Merge pull request #196 from RomainFranceschini/datetime-parse
Browse files Browse the repository at this point in the history
Clamp `AccessToken `expiration date to `DateTime` representable value
  • Loading branch information
darwin-morocho authored Dec 9, 2021
2 parents db7a393 + a4071f5 commit 5470493
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion facebook_auth_platform_interface/lib/src/access_token.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import 'dart:math';

const maxMillisecondsSinceEpoch = 8640000000000000;
const minMillisecondsSinceEpoch = -8640000000000000;

/// Class that contains the facebook access token data
class AccessToken {
/// DateTime with the expires date of this token
Expand Down Expand Up @@ -46,7 +51,12 @@ class AccessToken {
return AccessToken(
userId: json['userId'],
token: json['token'],
expires: DateTime.fromMillisecondsSinceEpoch(json['expires']),
expires: DateTime.fromMillisecondsSinceEpoch(
json['expires'].clamp(
minMillisecondsSinceEpoch,
maxMillisecondsSinceEpoch,
),
),
lastRefresh: DateTime.fromMillisecondsSinceEpoch(json['lastRefresh']),
applicationId: json['applicationId'],
graphDomain: json['graphDomain'],
Expand Down

0 comments on commit 5470493

Please sign in to comment.