@@ -123,15 +123,20 @@ public function authPreDispatch($event)
123
123
/** @var \Magento\Framework\App\State $adminAppState */
124
124
$ adminAppState = $ objectManager ->get ('Magento\Framework\App\State ' );
125
125
$ adminAppState ->setAreaCode (\Magento \Framework \App \Area::AREA_ADMIN );
126
- $ objectManager ->create (
127
- 'Magento\Backend\Model\Auth\Session ' ,
126
+ /** @var \Magento\Backend\Model\Session\AdminConfig $sessionConfig */
127
+ $ sessionConfig = $ objectManager ->get (\Magento \Backend \Model \Session \AdminConfig::class);
128
+ $ cookiePath = $ this ->getSetupCookiePath ($ objectManager );
129
+ $ sessionConfig ->setCookiePath ($ cookiePath );
130
+ /** @var \Magento\Backend\Model\Auth\Session $adminSession */
131
+ $ adminSession = $ objectManager ->create (
132
+ \Magento \Backend \Model \Auth \Session::class,
128
133
[
129
- 'sessionConfig ' => $ objectManager -> get ( ' Magento\Backend\Model\Session\AdminConfig ' ) ,
134
+ 'sessionConfig ' => $ sessionConfig ,
130
135
'appState ' => $ adminAppState
131
136
]
132
137
);
133
-
134
- if (! $ objectManager -> get ( ' Magento\Backend\Model\Auth ' )-> isLoggedIn ()) {
138
+ if (! $ objectManager -> get (\ Magento \ Backend \ Model \Auth::class)-> isLoggedIn ()) {
139
+ $ adminSession -> destroy ();
135
140
$ response = $ event ->getResponse ();
136
141
$ baseUrl = Http::getDistroBaseUrlPath ($ _SERVER );
137
142
$ response ->getHeaders ()->addHeaderLine ('Location ' , $ baseUrl . 'index.php/session/unlogin ' );
@@ -144,6 +149,25 @@ public function authPreDispatch($event)
144
149
return false ;
145
150
}
146
151
152
+ /**
153
+ * Get cookie path
154
+ *
155
+ * @param \Magento\Framework\ObjectManagerInterface $objectManager
156
+ * @return string
157
+ */
158
+ private function getSetupCookiePath (\Magento \Framework \ObjectManagerInterface $ objectManager )
159
+ {
160
+ /** @var \Magento\Backend\App\BackendAppList $backendAppList */
161
+ $ backendAppList = $ objectManager ->get (\Magento \Backend \App \BackendAppList::class);
162
+ $ backendApp = $ backendAppList ->getBackendApp ('setup ' );
163
+ /** @var \Magento\Backend\Model\UrlFactory $backendUrlFactory */
164
+ $ backendUrlFactory = $ objectManager ->get (\Magento \Backend \Model \UrlFactory::class);
165
+ $ baseUrl = parse_url ($ backendUrlFactory ->create ()->getBaseUrl (), PHP_URL_PATH );
166
+ $ baseUrl = \Magento \Framework \App \Request \Http::getUrlNoScript ($ baseUrl );
167
+ $ cookiePath = $ baseUrl . $ backendApp ->getCookiePath ();
168
+ return $ cookiePath ;
169
+ }
170
+
147
171
/**
148
172
* {@inheritdoc}
149
173
*/
0 commit comments