diff --git a/app/Classes/Modules/Accounts/ControllersLogic/RefreshAuthenticationTokenLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/RefreshAuthenticationTokenLogic.php new file mode 100644 index 00000000..9e4c5519 --- /dev/null +++ b/app/Classes/Modules/Accounts/ControllersLogic/RefreshAuthenticationTokenLogic.php @@ -0,0 +1,47 @@ + 'Refresh Authentication', + 'message' => 'You have successfully your account authentication' + ]; + } + + /** @var RefreshAuthenticationTokenProcessor */ + private $refreshAuthenticationTokenProcessor; + + /** + * RefreshAuthenticationTokenLogic constructor. + * @param RefreshAuthenticationTokenProcessor $refreshAuthenticationTokenProcessor + */ + public function __construct(RefreshAuthenticationTokenProcessor $refreshAuthenticationTokenProcessor) + { + $this->refreshAuthenticationTokenProcessor = $refreshAuthenticationTokenProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\InternalServerErrorException + */ + protected function logic(Request $request): JsonResponse { + + /** @var User $user */ + $user = Auth()->user(); + + return $this->response($this->refreshAuthenticationTokenProcessor->execute($user)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Processors/RefreshAuthenticationTokenProcessor.php b/app/Classes/Modules/Accounts/Processors/RefreshAuthenticationTokenProcessor.php new file mode 100644 index 00000000..288fcb1c --- /dev/null +++ b/app/Classes/Modules/Accounts/Processors/RefreshAuthenticationTokenProcessor.php @@ -0,0 +1,43 @@ +invalidatesAuthenticationToken = $invalidatesAuthenticationToken; + $this->generatesAuthenticationToken = $generatesAuthenticationToken; + } + + + /** + * @param User $user + * @return array + * @throws \App\Classes\Exceptions\InternalServerErrorException + */ + public function execute(User $user): array { + + $this->invalidatesAuthenticationToken->execute(); + + return ['refresh_token' => $this->generatesAuthenticationToken->execute($user)]; + + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Accounts/RefreshAuthenticationTokenController.php b/app/Http/Controllers/Accounts/RefreshAuthenticationTokenController.php new file mode 100644 index 00000000..ca783070 --- /dev/null +++ b/app/Http/Controllers/Accounts/RefreshAuthenticationTokenController.php @@ -0,0 +1,21 @@ +execute($request); + } + +} diff --git a/routes/account.php b/routes/account.php index 116a962a..a3609b29 100644 --- a/routes/account.php +++ b/routes/account.php @@ -16,6 +16,7 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account Route::group(['middleware' => 'valid.token'], function () { Route::get('/logout', 'UserAuthenticationLogoutController@logout')->name('logout'); + Route::get('/refresh', 'RefreshAuthenticationTokenController@refresh')->name('refresh'); }); }); });