@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * @author Temitope Olotin <[email protected]> |
|
| 4 | - * @license <https://opensource.org/license/MIT> MIT |
|
| 5 | - */ |
|
| 3 | + * @author Temitope Olotin <[email protected]> |
|
| 4 | + * @license <https://opensource.org/license/MIT> MIT |
|
| 5 | + */ |
|
| 6 | 6 | namespace Laztopaz\EmojiRestfulAPI; |
| 7 | 7 | |
| 8 | 8 | use Illuminate\Database\Capsule\Manager as Capsule; |
@@ -254,6 +254,8 @@ |
||
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * This method authenticate and return user id |
| 257 | + * @param Request $request |
|
| 258 | + * @param Response $response |
|
| 257 | 259 | */ |
| 258 | 260 | public function getCurrentUserId($request, $response) |
| 259 | 261 | { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $tokenId = base64_encode(mcrypt_create_iv(32)); |
| 67 | 67 | $issuedAt = time(); |
| 68 | - $notBefore = $issuedAt; //Adding 10 seconds |
|
| 68 | + $notBefore = $issuedAt; //Adding 10 seconds |
|
| 69 | 69 | $expire = $notBefore + (float) strtotime('+30 days'); // Adding 30 days expiry date |
| 70 | 70 | $serverName = "http://sweatemoji.com/api"; // Retrieve the server name |
| 71 | 71 | |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | * Create the token params as an array |
| 75 | 75 | */ |
| 76 | 76 | $data = [ |
| 77 | - 'iat' => $issuedAt, // Issued at: time when the token was generated |
|
| 78 | - 'jti' => $tokenId, // Json Token Id: an unique identifier for the token |
|
| 79 | - 'iss' => $serverName, // Issuer |
|
| 80 | - 'nbf' => $notBefore, // Not before |
|
| 81 | - 'exp' => $expire, // Expire |
|
| 77 | + 'iat' => $issuedAt, // Issued at: time when the token was generated |
|
| 78 | + 'jti' => $tokenId, // Json Token Id: an unique identifier for the token |
|
| 79 | + 'iss' => $serverName, // Issuer |
|
| 80 | + 'nbf' => $notBefore, // Not before |
|
| 81 | + 'exp' => $expire, // Expire |
|
| 82 | 82 | |
| 83 | 83 | 'dat' => $userData // User Information retrieved from the database |
| 84 | 84 | ]; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $secretKey = base64_decode(getenv('secret')); |
| 89 | 89 | |
| 90 | 90 | $jwt = JWT::encode( |
| 91 | - $data, //Data to be encoded in the JWT |
|
| 91 | + $data, //Data to be encoded in the JWT |
|
| 92 | 92 | $secretKey, // The signing key |
| 93 | 93 | 'HS512' // Algorithm used to sign the token |
| 94 | 94 | ); |