Skip to content
Permalink
Browse files

Fixing a bug where we were not passing in the ttl - thanks to Check N…

…orris (not the Texas Ranger kind) in the comments
  • Loading branch information
weaverryan committed Sep 15, 2016
1 parent 177607b commit 4e55471d8e940af6498ef8e3f79617d53518527a
Showing with 7 additions and 4 deletions.
  1. +6 −3 _tuts/jwt-token-finish-controller.diff
  2. +1 −1 _tuts/steps.json
@@ -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;
@@ -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")
*/
@@ -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]);
}
@@ -786,5 +786,5 @@
"description": null
}
],
"sha": "0552247405b73312a5027306f71fe973ba0bff59"
"sha": "177607b4737e1b8635c939e9ae48c38bfcda9c68"
}

0 comments on commit 4e55471

Please sign in to comment.
You can’t perform that action at this time.