Ejemplo n.º 1
0
 public function linkAction()
 {
     $this->acl->checkPermission('is logged in');
     $this->doNotRender();
     // Link external account.
     $user = $this->auth->getLoggedInUser();
     $provider_name = $this->getParam('provider');
     $ha_config = $this->_getHybridConfig();
     $hybridauth = new \Hybrid_Auth($ha_config);
     // try to authenticate with the selected provider
     $adapter = $hybridauth->authenticate($provider_name);
     if ($hybridauth->isConnectedWith($provider_name)) {
         $user_profile = $adapter->getUserProfile();
         UserExternal::processExternal($provider_name, $user_profile, $user);
         $this->alert('<b>Account successfully linked!</b>', 'green');
         $this->redirectToRoute(array('module' => 'default', 'controller' => 'profile'));
         return;
     }
 }