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

Add payloadData and expiration to the TokenExpiredException exception #63

Merged

Conversation

dstj
Copy link
Contributor

@dstj dstj commented Dec 6, 2016

Adding more contextual information to the TokenExpiredException for usage by the parent application

@abatishchev
Copy link
Member

Thanks for this change! I left few minor comments.

{
get
{
if (Data.Contains(PayloadDataKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this snippet to a helper method? To reuse, also make both getters one-liners. Also do we really need to check a key to exist? I'd let it throw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was debating whether to throw or not... The problem I have with throwing is that since you requested that TokenExpiredException inherits from SignationVerificationException (see PR #33), the Received and Expected properties will not be assigned for TokenExpiredException... so making a catch (SignationVerificationException ex) may crash if we don't do that...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's keep it safe. Can you please move it a helper? And remove a space inside the cast operator, to follow the common style.

@@ -264,7 +264,12 @@ public static void Verify(string payloadJson, string decodedCrypto, string decod
var secondsSinceEpoch = Math.Round((DateTime.UtcNow - UnixEpoch).TotalSeconds);
if (secondsSinceEpoch >= expInt)
{
throw new TokenExpiredException("Token has expired.");
var tokenExpiredException = new TokenExpiredException("Token has expired.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can throw right away, without a variable assignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, true, unfinished refactoring ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Can you please format the document (usually Ctrl+K,D) to make sure no extra/missing spaces were added/removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try. I'll need to change my settings, cause Ctrl-K,D will result in tabs all over otherwise! 😛

Copy link
Member

@abatishchev abatishchev Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I feel you pain, I'm a tabs guy too! Don't get me started 😉 Usually what I do is format then find and replace \t with (2 or 4 spaces).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe ;)
PR updated

{
get
{
if (Data.Contains(PayloadDataKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's keep it safe. Can you please move it a helper? And remove a space inside the cast operator, to follow the common style.

@abatishchev abatishchev merged commit 5f5bbd6 into jwt-dotnet:master Dec 7, 2016
@dstj dstj deleted the PR_TokenExpiredException_Improvement branch December 12, 2016 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants