Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed May 23, 2024
1 parent 735aa56 commit e8b9df2
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ public function __construct(
$this->updateSelectedLanguage();
}

protected function startSession(): void {

$session_start_settings =
$this->getAppSetting('session_start_options') !== null
? (array)$this->getAppSetting('session_start_options')
: [];
session_start($session_start_settings);
}

/**
* @psalm-suppress InvalidScalarArgument
*/
Expand All @@ -272,11 +281,7 @@ public function updateSelectedLanguage() : void {

if (session_status() !== \PHP_SESSION_ACTIVE) {

$session_start_settings =
$this->getAppSetting('session_start_options') !== null
? (array)$this->getAppSetting('session_start_options')
: [];
session_start($session_start_settings);
$this->startSession();
}

// also store in session
Expand Down Expand Up @@ -748,11 +753,7 @@ protected function doLogin(\Vespula\Auth\Auth $auth, array $credentials, string
//since we are successfully logged in, resume session if any
if (session_status() !== \PHP_SESSION_ACTIVE) {

$session_start_settings =
$this->getAppSetting('session_start_options') !== null
? (array)$this->getAppSetting('session_start_options')
: [];
session_start($session_start_settings);
$this->startSession();
}

} else {
Expand Down Expand Up @@ -1033,11 +1034,7 @@ public function storeCurrentUrlForLoginRedirection(): self {
//start a new session if none exists
if(session_status() !== \PHP_SESSION_ACTIVE) {

$session_start_settings =
$this->getAppSetting('session_start_options') !== null
? (array)$this->getAppSetting('session_start_options')
: [];
session_start($session_start_settings);
$this->startSession();
}

//store current url in session
Expand Down

0 comments on commit e8b9df2

Please sign in to comment.