diff --git a/src/core/controllers/AuthenticationController.php b/src/core/controllers/AuthenticationController.php index faa96dbcb7d1d1ced2616a2813f64dccd9ca801c..ac5b12794ac6dea403c9f57e1f8b2881ae29aff3 100755 --- a/src/core/controllers/AuthenticationController.php +++ b/src/core/controllers/AuthenticationController.php @@ -154,6 +154,8 @@ class AuthenticationController 'where' => ['id = ?'], 'data' => [$user['id']] ]); + $response = $response->withHeader('Token', AuthenticationController::getJWT()); + $response = $response->withHeader('Refresh-Token', $refreshToken); HistoryController::add([ 'code' => 'OK', @@ -163,9 +165,6 @@ class AuthenticationController 'message' => '{userLogIn}' ]); - $response = $response->withHeader('Token', AuthenticationController::getJWT()); - $response = $response->withHeader('Refresh-Token', $refreshToken); - return $response->withStatus(204); } @@ -195,9 +194,7 @@ class AuthenticationController $GLOBALS['id'] = $user['id']; - $response = $response->withHeader('Token', AuthenticationController::getJWT()); - - return $response->withStatus(204); + return $response->withJson(['token' => AuthenticationController::getJWT()]); } public static function getJWT() @@ -226,9 +223,9 @@ class AuthenticationController return $jwt; } - private static function getRefreshJWT() + public static function getRefreshJWT() { - $sessionTime = 1; + $sessionTime = AuthenticationController::MAX_DURATION_TOKEN; $loadedXml = CoreConfigModel::getConfig(); if ($loadedXml) { @@ -248,4 +245,18 @@ class AuthenticationController return $jwt; } + + public static function getResetJWT() + { + $token = [ + 'exp' => time() + 3600, + 'user' => [ + 'id' => $GLOBALS['id'] + ] + ]; + + $jwt = JWT::encode($token, CoreConfigModel::getEncryptKey()); + + return $jwt; + } }