ruby-jwt icon indicating copy to clipboard operation
ruby-jwt copied to clipboard

Make JWT::Signature.verify return true on success

Open bdewater opened this issue 6 years ago • 4 comments
trafficstars

Before this change it returns nil, this makes it easier to write code like

if JWT::Signature.verify(...)
  do_the_thing
end

bdewater avatar Apr 08 '19 00:04 bdewater

Hello, @bdewater! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

sourcelevel-bot[bot] avatar Apr 08 '19 00:04 sourcelevel-bot[bot]

@excpt I'd appreciate any feedback you'd have 🙂

bdewater avatar May 24 '19 16:05 bdewater

Im wondering if this method will ever return anything else than true and in all the other cases raise an exception?

You example could be just without the nesting.

JWT::Signature.verify(...)
do_the_thing

It's maybe not clear (and I'm not sure) that the verify method will always raise an exception when verification fails. Maybe we should make verify! an alias to that method that would indicate that it always rises when the token is not valid.

anakinj avatar Jul 02 '20 11:07 anakinj

Im wondering if this method will ever return anything else than true and in all the other cases raise an exception?

You example could be just without the nesting.

JWT::Signature.verify(...)
do_the_thing

It's maybe not clear (and I'm not sure) that the verify method will always raise an exception when verification fails. Maybe we should make verify! an alias to that method that would indicate that it always rises when the token is not valid.

You are correct.

This method will always raise an exception on error conditions.

This would be an improvement for a future release since it'll break the current behaviour.

I'll schedule this one for a 3.0.0 release.

excpt avatar Jul 07 '20 00:07 excpt

Im going to close this, gotten pretty stale already. Lets try to come up with a great api for the version 3.x

anakinj avatar Feb 02 '23 20:02 anakinj