Skip to content

Commit

Permalink
Merge pull request #14 from alexz707/StorageSessionIssue
Browse files Browse the repository at this point in the history
Storage session issue
  • Loading branch information
matwright authored Jan 19, 2021
2 parents d296b30 + 1b304d9 commit e0860c4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ LmcUser ChangeLog

V3.2.1
------------
* Added the ability to exchange the underlying hydrator for the user hydrator decorator.
*

* Fixed session storage name to be constant not dependent from used class.
* Added the ability to exchange the underlying hydrator for the user hydrator decorator.

V3.2.0
------------
Expand Down
7 changes: 7 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace LmcUser;

use Laminas\Hydrator\ClassMethodsHydrator;
Expand All @@ -9,12 +11,17 @@
use Laminas\ModuleManager\Feature\ServiceProviderInterface;
use LmcUser\Authentication\Adapter\Db;

/**
* Class Module
*/
class Module implements
ControllerProviderInterface,
ControllerPluginProviderInterface,
ConfigProviderInterface,
ServiceProviderInterface
{
public const LMC_USER_SESSION_STORAGE_NAMESPACE = 'LmcUserNamespace';

public function getConfig($env = null)
{
return include __DIR__ . '/config/module.config.php';
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://matwright.dev/"
}
],

"require": {
"php" : "^7.3",
"laminas/laminas-authentication" : "^2.7",
Expand Down
10 changes: 8 additions & 2 deletions src/LmcUser/Authentication/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php

declare(strict_types=1);

namespace LmcUser\Authentication\Adapter;

use Laminas\Authentication\Storage;
use LmcUser\Module;

/**
* Class AbstractAdapter
*/
abstract class AbstractAdapter implements ChainableAdapter
{
/**
Expand All @@ -21,7 +27,7 @@ abstract class AbstractAdapter implements ChainableAdapter
public function getStorage()
{
if (null === $this->storage) {
$this->setStorage(new Storage\Session(get_class($this)));
$this->setStorage(new Storage\Session(Module::LMC_USER_SESSION_STORAGE_NAMESPACE));
}

return $this->storage;
Expand Down Expand Up @@ -58,7 +64,7 @@ public function isSatisfied()
*/
public function setSatisfied($bool = true)
{
$storage = $this->getStorage()->read() ?: array();
$storage = $this->getStorage()->read() ?: [];
$storage['is_satisfied'] = $bool;
$this->getStorage()->write($storage);
return $this;
Expand Down
4 changes: 3 additions & 1 deletion src/LmcUser/Authentication/Adapter/ChainableAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace LmcUser\Authentication\Adapter;

use Laminas\Authentication\Storage\StorageInterface;
use Laminas\EventManager\EventInterface;

/**
* Interface ChainableAdapter
*/
interface ChainableAdapter
{
/**
Expand Down

0 comments on commit e0860c4

Please sign in to comment.