{"action":"created","issue":{"url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/127","labels_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/127/comments","events_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/127/events","html_url":"https://github.com/tymondesigns/jwt-auth/issues/127","id":81432899,"number":127,"title":"Using refresh middleware, token is invalid","user":{"login":"mattmcdonald-uk","id":1255436,"avatar_url":"https://avatars.githubusercontent.com/u/1255436?v=3","gravatar_id":"","url":"https://api.github.com/users/mattmcdonald-uk","html_url":"https://github.com/mattmcdonald-uk","followers_url":"https://api.github.com/users/mattmcdonald-uk/followers","following_url":"https://api.github.com/users/mattmcdonald-uk/following{/other_user}","gists_url":"https://api.github.com/users/mattmcdonald-uk/gists{/gist_id}","starred_url":"https://api.github.com/users/mattmcdonald-uk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattmcdonald-uk/subscriptions","organizations_url":"https://api.github.com/users/mattmcdonald-uk/orgs","repos_url":"https://api.github.com/users/mattmcdonald-uk/repos","events_url":"https://api.github.com/users/mattmcdonald-uk/events{/privacy}","received_events_url":"https://api.github.com/users/mattmcdonald-uk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-27T12:49:22Z","updated_at":"2015-05-27T22:39:44Z","closed_at":null,"body":"On my route I'm using the jwt.refresh middleware.\r\n\r\nI set the ttl to 1 to make sure refresh was working correctly, and encountered an issue.\r\n\r\nWhen I try to get the current user (JWTAuth::parseToken() -> toUser()) in my controller, because the token hasn't yet been refreshed the token is invalid and it throws an exception.\r\n\r\nAnother issue I encountered here was that instead of it throwing an exception that I could catch, it seems to throw an exception I can't catch - not sure why. But my error log shows: local.ERROR: exception 'Tymon\\JWTAuth\\Exceptions\\TokenExpiredException' with message 'Token has expired\r\n\r\nAttempts to catch TokenExpiredException don't work.\r\n\r\nThis issue occurs in 0.5.3 and in the latest dev version.\r\n\r\nMy workaround has been to modify RefreshToken so that the token is refresh before calling $next. Not sure whether this is a correct fix, or whether this might have an unwanted impact elsewhere."},"comment":{"url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/comments/106100817","html_url":"https://github.com/tymondesigns/jwt-auth/issues/127#issuecomment-106100817","issue_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/127","id":106100817,"user":{"login":"codeorganic","id":8428254,"avatar_url":"https://avatars.githubusercontent.com/u/8428254?v=3","gravatar_id":"","url":"https://api.github.com/users/codeorganic","html_url":"https://github.com/codeorganic","followers_url":"https://api.github.com/users/codeorganic/followers","following_url":"https://api.github.com/users/codeorganic/following{/other_user}","gists_url":"https://api.github.com/users/codeorganic/gists{/gist_id}","starred_url":"https://api.github.com/users/codeorganic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeorganic/subscriptions","organizations_url":"https://api.github.com/users/codeorganic/orgs","repos_url":"https://api.github.com/users/codeorganic/repos","events_url":"https://api.github.com/users/codeorganic/events{/privacy}","received_events_url":"https://api.github.com/users/codeorganic/received_events","type":"User","site_admin":false},"created_at":"2015-05-27T22:39:44Z","updated_at":"2015-05-27T22:39:44Z","body":"Yes I believe you are saying:\r\n\"->refresh()\" should not just blindly invalidate a token and it should check to make sure that it needs a refresh before\"  \r\n\r\nThis would fix the main issue with using ->refresh() in the current supplied middleware.\r\n\r\n"}}