14
14
use Magento \Integration \Model \ResourceModel \Oauth \Token \CollectionFactory as TokenCollectionFactory ;
15
15
use Magento \Integration \Model \Oauth \Token \RequestThrottler ;
16
16
use Magento \Framework \Exception \AuthenticationException ;
17
+ use Magento \Framework \Event \ManagerInterface ;
17
18
19
+ /**
20
+ * @inheritdoc
21
+ */
18
22
class CustomerTokenService implements \Magento \Integration \Api \CustomerTokenServiceInterface
19
23
{
20
24
/**
@@ -24,6 +28,11 @@ class CustomerTokenService implements \Magento\Integration\Api\CustomerTokenServ
24
28
*/
25
29
private $ tokenModelFactory ;
26
30
31
+ /**
32
+ * @var Magento\Framework\Event\ManagerInterface
33
+ */
34
+ private $ eventManager ;
35
+
27
36
/**
28
37
* Customer Account Service
29
38
*
@@ -55,21 +64,25 @@ class CustomerTokenService implements \Magento\Integration\Api\CustomerTokenServ
55
64
* @param AccountManagementInterface $accountManagement
56
65
* @param TokenCollectionFactory $tokenModelCollectionFactory
57
66
* @param \Magento\Integration\Model\CredentialsValidator $validatorHelper
67
+ * @param \Magento\Framework\Event\ManagerInterface $eventManager
58
68
*/
59
69
public function __construct (
60
70
TokenModelFactory $ tokenModelFactory ,
61
71
AccountManagementInterface $ accountManagement ,
62
72
TokenCollectionFactory $ tokenModelCollectionFactory ,
63
- CredentialsValidator $ validatorHelper
73
+ CredentialsValidator $ validatorHelper ,
74
+ ManagerInterface $ eventManager = null
64
75
) {
65
76
$ this ->tokenModelFactory = $ tokenModelFactory ;
66
77
$ this ->accountManagement = $ accountManagement ;
67
78
$ this ->tokenModelCollectionFactory = $ tokenModelCollectionFactory ;
68
79
$ this ->validatorHelper = $ validatorHelper ;
80
+ $ this ->eventManager = $ eventManager ?: \Magento \Framework \App \ObjectManager::getInstance ()
81
+ ->get (ManagerInterface::class);
69
82
}
70
83
71
84
/**
72
- * { @inheritdoc}
85
+ * @inheritdoc
73
86
*/
74
87
public function createCustomerAccessToken ($ username , $ password )
75
88
{
@@ -86,6 +99,7 @@ public function createCustomerAccessToken($username, $password)
86
99
)
87
100
);
88
101
}
102
+ $ this ->eventManager ->dispatch ('customer_login ' , ['customer ' => $ customerDataObject ]);
89
103
$ this ->getRequestThrottler ()->resetAuthenticationFailuresCount ($ username , RequestThrottler::USER_TYPE_CUSTOMER );
90
104
return $ this ->tokenModelFactory ->create ()->createCustomerToken ($ customerDataObject ->getId ())->getToken ();
91
105
}
0 commit comments