6
6
namespace Magento \Backend \Controller \Adminhtml \Auth ;
7
7
8
8
use Magento \Backend \App \Area \FrontNameResolver ;
9
+ use Magento \Backend \App \BackendAppList ;
9
10
use Magento \Backend \Model \UrlFactory ;
10
11
use Magento \Framework \App \Action \HttpGetActionInterface as HttpGet ;
11
12
use Magento \Framework \App \Action \HttpPostActionInterface as HttpPost ;
12
13
use Magento \Framework \App \ObjectManager ;
14
+ use Magento \Framework \App \Request \Http ;
13
15
14
16
/**
15
17
* @api
@@ -27,6 +29,11 @@ class Login extends \Magento\Backend\Controller\Adminhtml\Auth implements HttpGe
27
29
*/
28
30
private $ frontNameResolver ;
29
31
32
+ /**
33
+ * @var BackendAppList
34
+ */
35
+ private $ backendAppList ;
36
+
30
37
/**
31
38
* @var UrlFactory
32
39
*/
@@ -44,11 +51,13 @@ public function __construct(
44
51
\Magento \Backend \App \Action \Context $ context ,
45
52
\Magento \Framework \View \Result \PageFactory $ resultPageFactory ,
46
53
FrontNameResolver $ frontNameResolver = null ,
54
+ BackendAppList $ backendAppList = null ,
47
55
UrlFactory $ backendUrlFactory = null
48
56
) {
49
57
$ this ->resultPageFactory = $ resultPageFactory ;
50
58
parent ::__construct ($ context );
51
59
$ this ->frontNameResolver = $ frontNameResolver ?? ObjectManager::getInstance ()->get (FrontNameResolver::class);
60
+ $ this ->backendAppList = $ backendAppList ?? ObjectManager::getInstance ()->get (BackendAppList::class);
52
61
$ this ->backendUrlFactory = $ backendUrlFactory ?? ObjectManager::getInstance ()->get (UrlFactory::class);
53
62
}
54
63
@@ -96,9 +105,17 @@ private function getRedirect($path)
96
105
*/
97
106
private function isValidBackendUri (): bool
98
107
{
99
- $ backendFrontName = $ this ->frontNameResolver ->getFrontName ();
100
108
$ requestUri = $ this ->getRequest ()->getRequestUri ();
109
+ $ backendApp = $ this ->backendAppList ->getCurrentApp ();
101
110
$ baseUrl = parse_url ($ this ->backendUrlFactory ->create ()->getBaseUrl (), PHP_URL_PATH );
111
+ if (!$ backendApp ) {
112
+ $ backendFrontName = $ this ->frontNameResolver ->getFrontName ();
113
+ } else {
114
+ //In case of application authenticating through the admin login, the script name should be removed
115
+ //from the path, because application has own script.
116
+ $ baseUrl = Http::getUrlNoScript ($ baseUrl );
117
+ $ backendFrontName = $ backendApp ->getCookiePath ();
118
+ }
102
119
103
120
return strpos ($ requestUri , $ baseUrl . $ backendFrontName ) === 0 ;
104
121
}
0 commit comments