Skip to content

Instantly share code, notes, and snippets.

@asule90
Created December 9, 2018 05:51
Show Gist options
  • Save asule90/95dbffa359526d3b843ee1457a998ea2 to your computer and use it in GitHub Desktop.
Save asule90/95dbffa359526d3b843ee1457a998ea2 to your computer and use it in GitHub Desktop.
Code snippet for UserController example
$payload = [
'iss' => 'Organization', // Issuer of the token, Organization / Product
'sub' => 'subject', // Subject of the token
'iat' => time(), // Time when JWT was issued.
'exp' => time() + 60*60 // Expiration time
...
'user' => ...,
'desc' => ...,
];
$jwt = JWT::encode($payload, env('JWT_SECRET'));
$result = true;
$message = 'Login succeed';
$user_data = ...
return ['result'=>$result, 'message'=>$message, 'token'=>$jwt, 'user'=>$user_data];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment