From 745ad3b9e9c1c1a19693e76041018bd828c4a15d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 31 Jul 2017 10:23:39 -0400 Subject: [PATCH] better null checks for tokens --- src/App/Services/TokenService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App/Services/TokenService.cs b/src/App/Services/TokenService.cs index b9d2a2977..625c9cf77 100644 --- a/src/App/Services/TokenService.cs +++ b/src/App/Services/TokenService.cs @@ -93,10 +93,10 @@ namespace Bit.App.Services public bool TokenExpired => DateTime.UtcNow < TokenExpiration; public TimeSpan TokenTimeRemaining => TokenExpiration - DateTime.UtcNow; public bool TokenNeedsRefresh => TokenTimeRemaining.TotalMinutes < 5; - public string TokenUserId => DecodeToken()?["sub"].Value(); - public string TokenEmail => DecodeToken()?["email"].Value(); - public string TokenName => DecodeToken()?["name"].Value(); - public bool TokenPremium => (DecodeToken()?["premium"].Value()).GetValueOrDefault(false); + public string TokenUserId => DecodeToken()?["sub"]?.Value(); + public string TokenEmail => DecodeToken()?["email"]?.Value(); + public string TokenName => DecodeToken()?["name"]?.Value(); + public bool TokenPremium => DecodeToken()?["premium"]?.Value() ?? false; public string RefreshToken {