Skip to content

Commit

Permalink
Fixing a bug where we were not passing in the ttl - thanks to Check N…
Browse files Browse the repository at this point in the history
…orris (not the Texas Ranger kind) in the comments
  • Loading branch information
weaverryan committed Sep 15, 2016
1 parent 177607b commit 4e55471
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions _tuts/jwt-token-finish-controller.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/AppBundle/Controller/Api/TokenController.php b/src/AppBundle/Controller/Api/TokenController.php
index 790213b..ca6d70e 100644
index 790213b..402ade1 100644
--- a/src/AppBundle/Controller/Api/TokenController.php
+++ b/src/AppBundle/Controller/Api/TokenController.php
@@ -5,7 +5,10 @@ namespace AppBundle\Controller\Api;
Expand All @@ -13,7 +13,7 @@ index 790213b..ca6d70e 100644

class TokenController extends BaseController
{
@@ -13,8 +16,26 @@ class TokenController extends BaseController
@@ -13,8 +16,29 @@ class TokenController extends BaseController
* @Route("/api/tokens")
* @Method("POST")
*/
Expand All @@ -37,7 +37,10 @@ index 790213b..ca6d70e 100644
+ }
+
+ $token = $this->get('lexik_jwt_authentication.encoder')
+ ->encode(['username' => $user->getUsername()]);
+ ->encode([
+ 'username' => $user->getUsername(),
+ 'exp' => time() + 3600 // 1 hour expiration
+ ]);
+
+ return new JsonResponse(['token' => $token]);
}
Expand Down
2 changes: 1 addition & 1 deletion _tuts/steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -786,5 +786,5 @@
"description": null
}
],
"sha": "0552247405b73312a5027306f71fe973ba0bff59"
"sha": "177607b4737e1b8635c939e9ae48c38bfcda9c68"
}

0 comments on commit 4e55471

Please sign in to comment.