File tree Expand file tree Collapse file tree 3 files changed +59
-3
lines changed
app/code/Magento/LoginAsCustomerGraphQl/Model/Resolver
api-functional/testsuite/Magento/GraphQl/LoginAsCustomerGraphQl
integration/testsuite/Magento/LoginAsCustomer/_files Expand file tree Collapse file tree 3 files changed +59
-3
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ public function resolve(
76
76
array $ args = null
77
77
) {
78
78
$ isAllowedLogin = $ this ->authorization ->isAllowed ('Magento_LoginAsCustomer::login ' );
79
+ $ isAlllowedShoppingAssistance = $ this ->authorization ->isAllowed ('Magento_LoginAsCustomer::allow_shopping_assistance ' );
79
80
$ isEnabled = $ this ->config ->isEnabled ();
80
81
81
82
/* Get input params */
@@ -96,6 +97,13 @@ public function resolve(
96
97
__ ('Login as Customer is disabled. ' )
97
98
);
98
99
}
100
+
101
+ if (!$ isAlllowedShoppingAssistance ) {
102
+ throw new GraphQlAuthorizationException (
103
+ __ ('Allow remote shopping assistance is disabled. ' )
104
+ );
105
+ }
106
+
99
107
return $ this ->createCustomerToken ->execute (
100
108
$ args ['customer_email ' ],
101
109
$ context ->getExtensionAttributes ()->getStore ()
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ protected function setUp(): void
43
43
*
44
44
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/admin.php
45
45
* @magentoConfigFixture admin_store login_as_customer/general/enabled 1
46
- * @magentoApiDataFixture Magento/Customer /_files/customer.php
46
+ * @magentoApiDataFixture Magento/LoginAsCustomer /_files/customer.php
47
47
* @throws Exception
48
48
*/
49
49
public function testGenerateCustomerValidTokenLoginAsCustomerEnabled ()
@@ -67,7 +67,7 @@ public function testGenerateCustomerValidTokenLoginAsCustomerEnabled()
67
67
*
68
68
* @magentoApiDataFixture Magento/LoginAsCustomer/_files/admin.php
69
69
* @magentoConfigFixture admin_store login_as_customer/general/enabled 0
70
- * @magentoApiDataFixture Magento/Customer /_files/customer.php
70
+ * @magentoApiDataFixture Magento/LoginAsCustomer /_files/customer.php
71
71
* @throws Exception
72
72
*/
73
73
public function testGenerateCustomerValidTokenLoginAsCustomerDisabled ()
@@ -89,7 +89,7 @@ public function testGenerateCustomerValidTokenLoginAsCustomerDisabled()
89
89
/**
90
90
* Verify with Customer Token in auth header
91
91
*
92
- * @magentoApiDataFixture Magento/Customer /_files/customer.php
92
+ * @magentoApiDataFixture Magento/LoginAsCustomer /_files/customer.php
93
93
* @magentoConfigFixture admin_store login_as_customer/general/enabled 1
94
94
* @throws Exception
95
95
*/
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ declare (strict_types=1 );
8
+
9
+ use Magento \Customer \Model \CustomerRegistry ;
10
+ use Magento \Customer \Api \Data \CustomerExtensionFactory ;
11
+
12
+ $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
13
+ /** @var $repository \Magento\Customer\Api\CustomerRepositoryInterface */
14
+ $ repository = $ objectManager ->create (\Magento \Customer \Api \CustomerRepositoryInterface::class);
15
+ $ customer = $ objectManager ->create (\Magento \Customer \Model \Customer::class);
16
+
17
+ /** @var CustomerRegistry $customerRegistry */
18
+ $ customerRegistry = $ objectManager ->get (CustomerRegistry::class);
19
+ /** @var Magento\Customer\Model\Customer $customer */
20
+ $ customer ->setWebsiteId (1 )
21
+ ->setId (1 )
22
+
23
+ ->setPassword ('password ' )
24
+ ->setGroupId (1 )
25
+ ->setStoreId (1 )
26
+ ->setIsActive (1 )
27
+ ->setPrefix ('Mr. ' )
28
+ ->setFirstname ('John ' )
29
+ ->setMiddlename ('A ' )
30
+ ->setLastname ('Smith ' )
31
+ ->setSuffix ('Esq. ' )
32
+ ->setDefaultBilling (1 )
33
+ ->setDefaultShipping (1 )
34
+ ->setTaxvat ('12 ' )
35
+ ->setGender (0 );
36
+
37
+ $ extension = $ customer ->getExtensionAttributes ();
38
+ if ($ extension === null ) {
39
+ $ extension = $ objectManager ->get (CustomerExtensionFactory::class)->create ();
40
+ }
41
+
42
+ $ extension ->setAssistanceAllowed (2 );
43
+ $ customer ->setExtensionAttributes ($ extension );
44
+
45
+ $ customer ->isObjectNew (true );
46
+ $ customer ->save ();
47
+
48
+ $ customerRegistry ->remove ($ customer ->getId ());
You can’t perform that action at this time.
0 commit comments