Skip to content
This repository was archived by the owner on Mar 22, 2021. It is now read-only.

fixes token_lifetime with nil values issue#266

Open
muZk wants to merge 1 commit intonsarno:masterfrom
muZk:fix-verify-lifetime
Open

fixes token_lifetime with nil values issue#266
muZk wants to merge 1 commit intonsarno:masterfrom
muZk:fix-verify-lifetime

Conversation

@muZk
Copy link

@muZk muZk commented Jul 9, 2020

You can't have multiple entities where one of them has permanent tokens. This configuration would fail:

      Knock.token_lifetime = {
        user: nil,
        admin: 7.days,
      }

Because token_lifetime method assumes that if this is a hash, the values are dates/datetime:

def token_lifetime
      return unless verify_lifetime?

      if Knock.token_lifetime.is_a?(Hash)
        Knock.token_lifetime[entity_class_name].from_now.to_i // <---- here
      else
        Knock.token_lifetime.from_now.to_i
      end
end

This PR fixes the issue by updating verify_lifetime? method.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant