WIP commit
This commit is contained in:
parent
37690ee5af
commit
ca1a89039e
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
use RedBeanPHP\R;
|
||||
use Firebase\JWT;
|
||||
use Firebase\JWTi\JWT;
|
||||
|
||||
class Auth extends BaseController {
|
||||
|
||||
@ -10,8 +10,13 @@ class Auth extends BaseController {
|
||||
}
|
||||
|
||||
$jwt = $request->getHeader('Authorization');
|
||||
$payload = null;
|
||||
|
||||
try {
|
||||
$payload = JWT::decode($jwt, getJwtKey(), array('HS256'));
|
||||
} catch (Exception $ex) {
|
||||
}
|
||||
|
||||
// Validate token
|
||||
// Issue new token with extended expiration
|
||||
|
||||
return $response->withJson(json_encode($jwt));
|
||||
@ -40,6 +45,9 @@ class Auth extends BaseController {
|
||||
public function logout($request, $response, $args) {
|
||||
}
|
||||
|
||||
private function generateJwt() {
|
||||
}
|
||||
|
||||
private function getJwtKey() {
|
||||
$key = R::load('jwt', 1);
|
||||
|
||||
|
@ -178,6 +178,10 @@ class RequestMock {
|
||||
public function hasHeader() {
|
||||
return $this->hasHeader;
|
||||
}
|
||||
|
||||
public function getHeader($header) {
|
||||
return $header;
|
||||
}
|
||||
}
|
||||
|
||||
class ResponseMock {
|
||||
|
@ -26,6 +26,11 @@ class AuthTest extends PHPUnit_Framework_TestCase {
|
||||
new ResponseMock(), null);
|
||||
|
||||
$this->assertTrue($actual === 400);
|
||||
|
||||
$actual = $this->auth->authenticate(new RequestMock(),
|
||||
new ResponseMock(), null);
|
||||
|
||||
$this->assertTrue($actual === json_encode('Authorization'));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user