Skip to content

Commit

Permalink
MC-22829: Revert ticket MAGETWO-96975 which introduce BIC on 2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
svitja committed Nov 7, 2019
1 parent 7324325 commit 09de30c
Show file tree
Hide file tree
Showing 44 changed files with 717 additions and 640 deletions.
6 changes: 0 additions & 6 deletions app/code/Magento/Authorization/Model/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public function __construct( //phpcs:ignore Generic.CodeAnalysis.UselessOverridi

/**
* @inheritDoc
*
* @SuppressWarnings(PHPMD.SerializationAware)
* @deprecated Do not use PHP serialization.
*/
public function __sleep()
{
Expand All @@ -64,9 +61,6 @@ public function __sleep()

/**
* @inheritDoc
*
* @SuppressWarnings(PHPMD.SerializationAware)
* @deprecated Do not use PHP serialization.
*/
public function __wakeup()
{
Expand Down
204 changes: 5 additions & 199 deletions app/code/Magento/Backend/Model/Auth/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
*/
namespace Magento\Backend\Model\Auth;

use Magento\Framework\Acl;
use Magento\Framework\AclFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Backend\Spi\SessionUserHydratorInterface;
use Magento\Backend\Spi\SessionAclHydratorInterface;
use Magento\User\Model\User;
use Magento\User\Model\UserFactory;

/**
* Backend Auth session model
*
* @api
* @method \Magento\User\Model\User|null getUser()
* @method \Magento\Backend\Model\Auth\Session setUser(\Magento\User\Model\User $value)
* @method \Magento\Framework\Acl|null getAcl()
* @method \Magento\Backend\Model\Auth\Session setAcl(\Magento\Framework\Acl $value)
* @method int getUpdatedAt()
* @method \Magento\Backend\Model\Auth\Session setUpdatedAt(int $value)
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @todo implement solution that keeps is_first_visit flag in session during redirects
* @api
* @since 100.0.2
Expand Down Expand Up @@ -59,36 +55,6 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
*/
protected $_config;

/**
* @var SessionUserHydratorInterface
*/
private $userHydrator;

/**
* @var SessionAclHydratorInterface
*/
private $aclHydrator;

/**
* @var UserFactory
*/
private $userFactory;

/**
* @var AclFactory
*/
private $aclFactory;

/**
* @var User|null
*/
private $user;

/**
* @var Acl|null
*/
private $acl;

/**
* @param \Magento\Framework\App\Request\Http $request
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
Expand All @@ -103,10 +69,6 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
* @param \Magento\Backend\Model\UrlInterface $backendUrl
* @param \Magento\Backend\App\ConfigInterface $config
* @throws \Magento\Framework\Exception\SessionException
* @param SessionUserHydratorInterface|null $userHydrator
* @param SessionAclHydratorInterface|null $aclHydrator
* @param UserFactory|null $userFactory
* @param AclFactory|null $aclFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -121,19 +83,11 @@ public function __construct(
\Magento\Framework\App\State $appState,
\Magento\Framework\Acl\Builder $aclBuilder,
\Magento\Backend\Model\UrlInterface $backendUrl,
\Magento\Backend\App\ConfigInterface $config,
?SessionUserHydratorInterface $userHydrator = null,
?SessionAclHydratorInterface $aclHydrator = null,
?UserFactory $userFactory = null,
?AclFactory $aclFactory = null
\Magento\Backend\App\ConfigInterface $config
) {
$this->_config = $config;
$this->_aclBuilder = $aclBuilder;
$this->_backendUrl = $backendUrl;
$this->userHydrator = $userHydrator ?? ObjectManager::getInstance()->get(SessionUserHydratorInterface::class);
$this->aclHydrator = $aclHydrator ?? ObjectManager::getInstance()->get(SessionAclHydratorInterface::class);
$this->userFactory = $userFactory ?? ObjectManager::getInstance()->get(UserFactory::class);
$this->aclFactory = $aclFactory ?? ObjectManager::getInstance()->get(AclFactory::class);
parent::__construct(
$request,
$sidResolver,
Expand Down Expand Up @@ -277,16 +231,6 @@ public function processLogin()
return $this;
}

/**
* @inheritDoc
*/
public function destroy(array $options = null)
{
$this->user = null;
$this->acl = null;
parent::destroy($options);
}

/**
* Process of configuring of current auth storage when logout was performed
*
Expand All @@ -310,142 +254,4 @@ public function isValidForPath($path)
{
return true;
}

/**
* Logged-in user.
*
* @return User|null
*/
public function getUser()
{
if (!$this->user) {
$userData = $this->getUserData();
if ($userData) {
/** @var User $user */
$user = $this->userFactory->create();
$this->userHydrator->hydrate($user, $userData);
$this->user = $user;
} elseif ($user = parent::getUser()) {
$this->setUser($user);
}
}

return $this->user;
}

/**
* Set logged-in user instance.
*
* @param User|null $user
* @return Session
*/
public function setUser($user)
{
$this->setUserData(null);
if ($user) {
$this->setUserData($this->userHydrator->extract($user));
}
$this->user = $user;

return $this;
}

/**
* Is user logged in?
*
* @return bool
*/
public function hasUser()
{
return (bool)$this->getUser();
}

/**
* Remove logged-in user.
*
* @return Session
*/
public function unsUser()
{
$this->user = null;
parent::unsUser();
return $this->unsUserData();
}

/**
* Logged-in user's ACL data.
*
* @return Acl|null
*/
public function getAcl()
{
if (!$this->acl) {
$aclData = $this->getUserAclData();
if ($aclData) {
/** @var Acl $acl */
$acl = $this->aclFactory->create();
$this->aclHydrator->hydrate($acl, $aclData);
$this->acl = $acl;
} elseif ($acl = parent::getAcl()) {
$this->setAcl($acl);
}
}

return $this->acl;
}

/**
* Set logged-in user's ACL data instance.
*
* @param Acl|null $acl
* @return Session
*/
public function setAcl($acl)
{
$this->setUserAclData(null);
if ($acl) {
$this->setUserAclData($this->aclHydrator->extract($acl));
}
$this->acl = $acl;

return $this;
}

/**
* Whether ACL data is present.
*
* @return bool
*/
public function hasAcl()
{
return (bool)$this->getAcl();
}

/**
* Remove ACL data.
*
* @return Session
*/
public function unsAcl()
{
$this->acl = null;
parent::unsAcl();
return $this->unsUserAclData();
}

/**
* @inheritDoc
*/
public function writeClose()
{
//Updating data in session in case these objects has been changed.
if ($this->user) {
$this->setUser($this->user);
}
if ($this->acl) {
$this->setAcl($this->acl);
}

parent::writeClose();
}
}
36 changes: 0 additions & 36 deletions app/code/Magento/Backend/Model/Auth/SessionAclHydrator.php

This file was deleted.

54 changes: 0 additions & 54 deletions app/code/Magento/Backend/Model/Auth/SessionUserHydrator.php

This file was deleted.

Loading

0 comments on commit 09de30c

Please sign in to comment.