11
11
use Magento \Framework \Webapi \Rest \Request as RestRequest ;
12
12
use Magento \Customer \Api \Data \CustomerInterface ;
13
13
use Magento \Customer \Api \CustomerRepositoryInterface ;
14
- use Magento \Framework \App \ObjectManager ;
15
- use Magento \Integration \Model \Oauth \Token ;
16
14
17
15
/**
18
16
* Update customer by id from request param
@@ -24,22 +22,12 @@ class UpdateCustomer
24
22
*/
25
23
private $ request ;
26
24
27
- /**
28
- * @var Token
29
- */
30
- private $ token ;
31
-
32
25
/**
33
26
* @param RestRequest $request
34
- * @param Token|null $token
35
27
*/
36
- public function __construct (
37
- RestRequest $ request ,
38
- Token $ token = null
39
- ) {
28
+ public function __construct (RestRequest $ request )
29
+ {
40
30
$ this ->request = $ request ;
41
- $ this ->token = $ token ?: ObjectManager::getInstance ()
42
- ->get (Token::class);
43
31
}
44
32
45
33
/**
@@ -56,17 +44,9 @@ public function beforeSave(
56
44
?string $ passwordHash = null
57
45
): array {
58
46
$ customerId = $ this ->request ->getParam ('customerId ' );
59
- $ cookie = $ this ->request ->getHeader ('cookie ' );
60
- $ headerToken = $ this ->request ->getHeader ('Authorization ' );
61
- if ($ customerId && !str_contains ($ cookie , 'PHPSESSID ' )) {
62
- if (str_contains ($ headerToken , 'Bearer ' )) {
63
- $ token = "Bearer " . $ this ->token ->loadByCustomerId ($ customerId )->getData ('token ' );
64
- if ($ headerToken === $ token ) {
65
- $ customer = $ this ->getUpdatedCustomer ($ customerRepository ->getById ($ customerId ), $ customer );
66
- }
67
- } else {
68
- $ customer = $ this ->getUpdatedCustomer ($ customerRepository ->getById ($ customerId ), $ customer );
69
- }
47
+ $ bodyParams = $ this ->request ->getBodyParams ();
48
+ if (!isset ($ bodyParams ['customer ' ]['Id ' ]) && $ customerId ) {
49
+ $ customer = $ this ->getUpdatedCustomer ($ customerRepository ->getById ($ customerId ), $ customer );
70
50
}
71
51
72
52
return [$ customer , $ passwordHash ];
0 commit comments