From 0a039cb1441100c0b8cc5ddd856f4e4bb9a0c9de Mon Sep 17 00:00:00 2001 From: eliasjpr Date: Mon, 7 Oct 2024 21:26:58 -0400 Subject: [PATCH] Refine revoked getter and improve enumeration Changed the `revoked` getter to a nilable type for consistent handling of null values in JSON serialization, avoiding potential bugs. Improved the `each` method in the in-memory JTI provider by utilizing block notation, simplifying code readability and maintainability. These enhancements streamline data handling and iteration in the codebase. --- src/authly/access_token.cr | 2 +- src/authly/in_memory_jti_provider.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/authly/access_token.cr b/src/authly/access_token.cr index 47fc2e4..baa87ef 100644 --- a/src/authly/access_token.cr +++ b/src/authly/access_token.cr @@ -9,7 +9,7 @@ module Authly getter access_token : String getter token_type : String = "Bearer" getter expires_in : Int64 = ACCESS_TTL.from_now.to_unix - getter revoked : Bool = false + getter? revoked : Bool = false @[JSON::Field(emit_null: false)] getter refresh_token : String @[JSON::Field(emit_null: false)] diff --git a/src/authly/in_memory_jti_provider.cr b/src/authly/in_memory_jti_provider.cr index 5e3e8c4..e17e78f 100644 --- a/src/authly/in_memory_jti_provider.cr +++ b/src/authly/in_memory_jti_provider.cr @@ -9,7 +9,7 @@ module Authly end # Implement the each method to make the class enumerable - def each + def each(&) @revoked_tokens.each { |jti| yield jti } end