diff --git a/azure-auth/Azure/Utils.hs b/azure-auth/Azure/Utils.hs index 978b969..64d0664 100644 --- a/azure-auth/Azure/Utils.hs +++ b/azure-auth/Azure/Utils.hs @@ -1,6 +1,6 @@ module Azure.Utils where -import Data.Time (addUTCTime, getCurrentTime, secondsToNominalDiffTime) +import Data.Time (getCurrentTime, secondsToNominalDiffTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import UnliftIO (MonadIO (..)) @@ -9,15 +9,13 @@ import Azure.Types (ExpiresOn) import qualified Data.Text as Text import qualified Text.Read as Text -{- | Check if an azure access token expiration time -is past or < 20 seconds from current time --} +-- | Check if an azure access token has expired isExpired :: MonadIO m => ExpiresOn -> m Bool isExpired expiresOn = do let timestamp = posixSecondsToUTCTime . secondsToNominalDiffTime <$> Text.readMaybe (Text.unpack expiresOn) case timestamp of Just time -> do currentTime <- liftIO getCurrentTime - return $ time <= addUTCTime 20 currentTime + return $ time <= currentTime Nothing -> return False