Created
April 10, 2017 16:51
-
-
Save miedzwin/0207abe651f9f47b290e61916bbfb295 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
namespace Front\Service; | |
use Api\Service\AuthService; | |
use Hybrid_User_Profile; | |
use Entity\User; | |
class HybridAuthService extends AuthService { | |
public function initService() { | |
parent::initService(); | |
} | |
public function loginUser(Hybrid_User_Profile $userProfile) { | |
$customAdapter = $this->getServiceLocator()->get('ObjectRepository'); | |
// Get Zend's auth service | |
/* @var $authService \Zend\Authentication\AuthenticationService */ | |
$authService = $this->getZendAuthService(); | |
// Grab the adapter and set the credentials | |
$adapter = $authService->getAdapter(); | |
// ddd($adapter); | |
$adapter->setIdentityValue($userProfile->email); | |
$adapter->setCredentialValue($userProfile->identifier); | |
$authenticationResult = $authService->authenticate(); | |
ddd($authenticationResult); | |
ddd($authenticationResult); | |
} | |
} |
This file contains 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
<?php | |
namespace Front\Authentication\Adapter; | |
use DoctrineModule\Authentication\Adapter\ObjectRepository as BaseObjectRepository; | |
use Zend\Authentication\Result as AuthenticationResult; | |
class ObjectRepository extends BaseObjectRepository { | |
/** | |
* Custom identity validator based on facebook id | |
* @return type | |
*/ | |
public function authenticate() { | |
$this->setup(); | |
$options = $this->options; | |
$identity = $options | |
->getObjectRepository() | |
->findOneBy([ | |
$options->getIdentityProperty() => $this->identity, | |
'facebook_identifier' => $this->credential, | |
]); | |
if (!$identity) { | |
$this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND; | |
$this->authenticationResultInfo['messages'][] = 'A record with the supplied identity could not be found'; | |
return $this->createAuthenticationResult(); | |
} | |
$authResult = $this->validateIdentity($identity); | |
return $authResult; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment