protected function _touch(array $data)
{
try {
if (empty($data['provider']) && !empty($this->_provider)) {
$data['provider'] = SocialUtils::getProvider($this->_provider);
}
$user = $this->_socialLogin($data);
} catch (UserNotActiveException $ex) {
$exception = $ex;
} catch (AccountNotActiveException $ex) {
$exception = $ex;
} catch (MissingEmailException $ex) {
$exception = $ex;
}
if (!empty($exception)) {
$args = ['exception' => $exception, 'rawData' => $data];
$event = $this->_getController()->dispatchEvent(UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, $args);
if (method_exists($this->_getController(), 'failedSocialLogin')) {
$this->_getController()->failedSocialLogin($exception, $data, true);
}
return $event->result;
}
// If new SocialAccount was created $user is returned containing it
if ($user->get('social_accounts')) {
$this->_getController()->dispatchEvent(UsersAuthComponent::EVENT_AFTER_REGISTER, compact('user'));
}
if (!empty($user->username)) {
$user = $this->_findUser($user->username);
}
return $user;
}