mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
in depth look at Logincontroller timings
This commit is contained in:
parent
4895417586
commit
cf8e285b62
|
|
@ -10,16 +10,21 @@ use \Grocy\Services\UsersService;
|
|||
class BaseController
|
||||
{
|
||||
public function __construct(\Slim\Container $container) {
|
||||
$fp = fopen('/config/data/sql.log', 'a');
|
||||
$time_start = microtime(true);
|
||||
$databaseService = DatabaseService::getInstance();
|
||||
$this->Database = $databaseService->GetDbConnection();
|
||||
fwrite($fp, "%%% Login controller - parent construstor database time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
|
||||
$localizationService = LocalizationService::getInstance(GROCY_CULTURE);
|
||||
$this->LocalizationService = $localizationService;
|
||||
fwrite($fp, "%%% Login controller - parent construstor localisation time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
|
||||
$applicationService = ApplicationService::getInstance();
|
||||
$versionInfo = $applicationService->GetInstalledVersion();
|
||||
$container->view->set('version', $versionInfo->Version);
|
||||
$container->view->set('releaseDate', $versionInfo->ReleaseDate);
|
||||
fwrite($fp, "%%% Login controller - parent construstor application service time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
|
||||
$container->view->set('__t', function(string $text, ...$placeholderValues) use($localizationService)
|
||||
{
|
||||
|
|
@ -54,6 +59,7 @@ class BaseController
|
|||
$container->view->set('featureFlags', $constants);
|
||||
|
||||
$container->view->set('userentitiesForSidebar', $this->Database->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
|
||||
fwrite($fp, "%%% Login controller - parent construstor view time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -73,6 +79,8 @@ class BaseController
|
|||
}
|
||||
|
||||
$this->AppContainer = $container;
|
||||
fwrite($fp, "%%% Login controller - parent construstor total time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
protected $AppContainer;
|
||||
|
|
|
|||
|
|
@ -14,16 +14,25 @@ class LoginController extends BaseController
|
|||
$time_start = microtime(true);
|
||||
parent::__construct($container);
|
||||
fwrite($fp, "£££ Login controller - parent construstor time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
$this->SessionService = SessionService::getInstance();
|
||||
fwrite($fp, "£££ Login controller - got session service instance : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
#$this->SessionService = SessionService::getInstance();
|
||||
#fwrite($fp, "£££ Login controller - got session service instance : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
$this->SessionCookieName = $sessionCookieName;
|
||||
fwrite($fp, "£££ Login controller - construction time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
protected $SessionService;
|
||||
protected $SessionService = null;
|
||||
protected $SessionCookieName;
|
||||
|
||||
private function getSessionService()
|
||||
{
|
||||
if($this->SessionsService == null)
|
||||
{
|
||||
$this->SessionService = SessionService::getInstance();
|
||||
}
|
||||
return $this->SessionService;
|
||||
}
|
||||
|
||||
public function ProcessLogin(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$fp = fopen('/config/data/sql.log', 'a');
|
||||
|
|
@ -38,7 +47,7 @@ class LoginController extends BaseController
|
|||
|
||||
if ($user !== null && password_verify($inputPassword, $user->password))
|
||||
{
|
||||
$sessionKey = $this->SessionService->CreateSession($user->id, $stayLoggedInPermanently);
|
||||
$sessionKey = $this->getSessionService()->CreateSession($user->id, $stayLoggedInPermanently);
|
||||
setcookie($this->SessionCookieName, $sessionKey, PHP_INT_SIZE == 4 ? PHP_INT_MAX : PHP_INT_MAX>>32); // Cookie expires never, but session validity is up to SessionService
|
||||
|
||||
if (password_needs_rehash($user->password, PASSWORD_DEFAULT))
|
||||
|
|
@ -68,7 +77,7 @@ class LoginController extends BaseController
|
|||
|
||||
public function Logout(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$this->SessionService->RemoveSession($_COOKIE[$this->SessionCookieName]);
|
||||
$this->getSessionService()->RemoveSession($_COOKIE[$this->SessionCookieName]);
|
||||
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/'));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user