ruby-jwt
ruby-jwt copied to clipboard
Make JWT::Signature.verify return true on success
Before this change it returns nil, this makes it easier to write code like
if JWT::Signature.verify(...)
do_the_thing
end
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.
@excpt I'd appreciate any feedback you'd have 🙂
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.
Im wondering if this method will ever return anything else than
trueand in all the other cases raise an exception?You example could be just without the nesting.
JWT::Signature.verify(...) do_the_thingIt's maybe not clear (and I'm not sure) that the
verifymethod will always raise an exception when verification fails. Maybe we should makeverify!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.
Im going to close this, gotten pretty stale already. Lets try to come up with a great api for the version 3.x