mirror of
https://github.com/grocy/grocy.git
synced 2025-08-14 17:54:40 +00:00
More authentication refactoring to also provide "plugable" credentials handling (references #921, needed for #305)
This commit is contained in:
@@ -8,12 +8,9 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
class SessionAuthMiddleware extends AuthMiddleware
|
||||
{
|
||||
protected $SessionCookieName;
|
||||
|
||||
public function __construct(\DI\Container $container, ResponseFactoryInterface $responseFactory)
|
||||
{
|
||||
parent::__construct($container, $responseFactory);
|
||||
$this->SessionCookieName = $this->AppContainer->get('LoginControllerInstance')->GetSessionCookieName();
|
||||
}
|
||||
|
||||
public function authenticate(Request $request)
|
||||
@@ -25,13 +22,18 @@ class SessionAuthMiddleware extends AuthMiddleware
|
||||
|
||||
$sessionService = SessionService::getInstance();
|
||||
|
||||
if (!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName]))
|
||||
if (!isset($_COOKIE[SessionService::SESSION_COOKIE_NAME]) || !$sessionService->IsValidSession($_COOKIE[SessionService::SESSION_COOKIE_NAME]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $sessionService->GetUserBySessionKey($_COOKIE[$this->SessionCookieName]);
|
||||
return $sessionService->GetUserBySessionKey($_COOKIE[SessionService::SESSION_COOKIE_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function ProcessLogin(array $postParams)
|
||||
{
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user