8
8
9
9
use Magento \Authorization \Model \UserContextInterface ;
10
10
use Magento \Customer \Model \CustomerFactory ;
11
+ use Magento \Customer \Model \ResourceModel \Customer as CustomerResource ;
11
12
use Magento \Integration \Api \AuthorizationServiceInterface as AuthorizationService ;
12
13
use Magento \Store \Model \StoreManagerInterface ;
13
14
@@ -24,29 +25,37 @@ class CustomerAuthorization
24
25
private $ userContext ;
25
26
26
27
/**
27
- * @var StoreManagerInterface
28
+ * @var CustomerFactory
28
29
*/
29
- private $ storeManager ;
30
+ private $ customerFactory ;
30
31
31
32
/**
32
- * @var CustomerFactory
33
+ * @var CustomerResource
33
34
*/
34
- private $ customerFactory ;
35
+ private $ customerResource ;
36
+
37
+ /**
38
+ * @var StoreManagerInterface
39
+ */
40
+ private $ storeManager ;
35
41
36
42
/**
37
43
* Inject dependencies.
38
44
*
39
45
* @param UserContextInterface $userContext
40
46
* @param CustomerFactory $customerFactory
47
+ * @param CustomerResource $customerResource
41
48
* @param StoreManagerInterface $storeManager
42
49
*/
43
50
public function __construct (
44
51
UserContextInterface $ userContext ,
45
52
CustomerFactory $ customerFactory ,
53
+ CustomerResource $ customerResource ,
46
54
StoreManagerInterface $ storeManager
47
55
) {
48
56
$ this ->userContext = $ userContext ;
49
57
$ this ->customerFactory = $ customerFactory ;
58
+ $ this ->customerResource = $ customerResource ;
50
59
$ this ->storeManager = $ storeManager ;
51
60
}
52
61
@@ -72,7 +81,8 @@ public function aroundIsAllowed(
72
81
&& $ this ->userContext ->getUserId ()
73
82
&& $ this ->userContext ->getUserType () === UserContextInterface::USER_TYPE_CUSTOMER
74
83
) {
75
- $ customer = $ this ->customerFactory ->create ()->load ($ this ->userContext ->getUserId ());
84
+ $ customer = $ this ->customerFactory ->create ();
85
+ $ this ->customerResource ->load ($ customer , $ this ->userContext ->getUserId ());
76
86
$ currentStoreId = $ this ->storeManager ->getStore ()->getId ();
77
87
$ sharedStoreIds = $ customer ->getSharedStoreIds ();
78
88
if (in_array ($ currentStoreId , $ sharedStoreIds )) {
0 commit comments