Open LabiciIvan opened 1 month ago
Note:
Small refactorisation and enhancement in the BaseMiddleware::class
, to use DependencyInjector::class and to inject all dependencies a middleware has.
Refactored the instance of the dependencies in case of Request::class
to get it from the request.php
file as there is the place the request is created and by creating a new instance of the Request::class
we lose important data as it is no longer pointing to initial instance of the class.
Description:
Create a new directory in the
App/
with the name of Middlewares.In the
/App/Middlewares/
create a new classAuthenticationMiddleware::class
This class will be responsible to check if the given user is authenticated in the application by returning a response to the user in cases where user is not authenticated or if user is authenticated continue the action.
AuthenticationMiddleware::class
will have the following capabilities and methods:Request:: class $request
and extract the user email;public function isAuthenticated()
:Register this middleware in the
App/Classes/BaseMiddleware.php
file in$registeredMiddlewares
array variable.