Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update method to accept either token as string or Token class instance #153

Closed
wants to merge 1 commit into from

Conversation

hernandev
Copy link

@hernandev hernandev commented Jan 16, 2018

This PR allows for verifyIdToken method on Auth class to accept both a string or a Token instance.

Fixes #152

@jeromegamez
Copy link
Member

jeromegamez commented Jan 16, 2018

Are you sure? The used Verifier (https://github.com/kreait/firebase-tokens-php/blob/master/src/Verifier.php#L41) parses an ID token string already, and I couldn't recreate the issue.

Just to be sure, I added unit and integration tests with b3bd435.

But indeed, you made me aware of something: values that couldn't be parsed as a token at all (such as integer, bools, null) would trigger an unexpected error, but I believe that I was able to fix it with and f370001.

Could you please rebase your branch and check if this still doesn't work for you? I hope that my second change fixed the real culprit.

You can execute the unit test suite with make tests or vendor/bin/phpunit --testsuite unit.

@hernandev
Copy link
Author

Could be some caching, I'll get back to you.

@hernandev
Copy link
Author

This is the error:

TypeError: Argument 1 passed to Kreait\Firebase\Exception\Auth\InvalidIdToken::__construct() must be an instance of Lcobucci\JWT\Token, string given, called in /var/www/app/vendor/kreait/firebase-php/src/Firebase/Auth/IdTokenVerifier.php on line 33

@hernandev
Copy link
Author

Ok, you got the line, after a exception is raised, the string is being passed to the Exception instance, which does not know how to handle strings.

That's why this PR fixed it, but by the wrong way since it will be trying to parse it on two places.

I would recommend you to parse as soon as possible on the flow to avoid a "is it already parsed" question everywhere.

So, gonna close this, you can solve with the best approach!

See ya!

@hernandev hernandev closed this Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants