-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
*/.DS_Store | ||
cache | ||
cache | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* This file is part of the O2System PHP Framework package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Steeve Andrian Salim | ||
* @copyright Copyright (c) Steeve Andrian Salim | ||
*/ | ||
|
||
// ------------------------------------------------------------------------ | ||
|
||
namespace App\Http\Middleware; | ||
|
||
// ------------------------------------------------------------------------ | ||
|
||
use O2System\Psr\Http\Message\ServerRequestInterface; | ||
use O2System\Psr\Http\Server\RequestHandlerInterface; | ||
|
||
/** | ||
* Class JsonWebToken | ||
* | ||
* @package O2System\Framework\Http\Middleware | ||
*/ | ||
class JsonWebToken implements RequestHandlerInterface | ||
{ | ||
/** | ||
* JsonWebToken::handle | ||
* | ||
* Handles a request and produces a response | ||
* | ||
* May call other collaborating code to generate the response. | ||
*/ | ||
public function handle(ServerRequestInterface $request) | ||
{ | ||
if (services()->has('jsonWebTokenAuthentication')) { | ||
if(false !== ($token = input()->bearerToken())) { | ||
print_out($token); | ||
$payload = services('jsonWebTokenAuthentication')->decode($token); | ||
globals()->store('payload', $payload); | ||
} else { | ||
output()->sendError(403, [ | ||
'message' => language()->getLine('403_INVALID_JSONWEBTOKEN') | ||
]); | ||
} | ||
} | ||
} | ||
} |