Created
May 29, 2017 07:53
-
-
Save phamngsinh/3a7c21a1cad15562607519fe698b71ff to your computer and use it in GitHub Desktop.
Get Token Authentication For Customer Logged With Facebook & Twitter : Magento 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function createCustomerAccessToken($username, $password) | |
| { | |
| $this->validatorHelper->validate($username, $password); | |
| $this->getRequestThrottler()->throttle($username, RequestThrottler::USER_TYPE_CUSTOMER); | |
| try { | |
| $customerDataObject = $this->accountManagement->authenticate($username, $password); | |
| } catch (\Exception $e) { | |
| $this->getRequestThrottler()->logAuthenticationFailure($username, RequestThrottler::USER_TYPE_CUSTOMER); | |
| throw new AuthenticationException( | |
| __('You did not sign in correctly or your account is temporarily disabled.') | |
| ); | |
| } | |
| $this->getRequestThrottler()->resetAuthenticationFailuresCount($username, RequestThrottler::USER_TYPE_CUSTOMER); | |
| return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment