public function indexAction()
 {
     $model = new Users_Model_User();
     //        $namespace = new Zend_Session_Namespace('userInfo');
     //        $namespace->user_id = 17;
     //        $namespace->user_fname = 'Ankit';
     //        $namespace->user_lname = 'Sharma';
     //        $namespace->user_img = $img;
     if (!isset($_SESSION)) {
         $auth = TBS\Auth::getInstance();
         $providers = $auth->getIdentity();
         // Here the response of the providers are registered
         if ($this->_hasParam('provider')) {
             $provider = $this->_getParam('provider');
             switch ($provider) {
                 case "facebook":
                     if ($this->_hasParam('code')) {
                         $adapter = new TBS\Auth\Adapter\Facebook($this->_getParam('code'));
                         $result = $auth->authenticate($adapter);
                     }
                     if ($this->_hasParam('error')) {
                         throw new Zend_Controller_Action_Exception('Facebook login failed, response is: ' . $this->_getParam('error'));
                     }
                     break;
                 case "twitter":
                     if ($this->_hasParam('oauth_token')) {
                         $adapter = new TBS\Auth\Adapter\Twitter($_GET);
                         $result = $auth->authenticate($adapter);
                     }
                     break;
                 case "google":
                     if ($this->_hasParam('code')) {
                         $adapter = new TBS\Auth\Adapter\Google($this->_getParam('code'));
                         $result = $auth->authenticate($adapter);
                     }
                     if ($this->_hasParam('error')) {
                         throw new Zend_Controller_Action_Exception('Google login failed, response is: ' . $this->_getParam('error'));
                     }
                     break;
             }
             // What to do when invalid
             if (isset($result) && !$result->isValid()) {
                 $auth->clearIdentity($this->_getParam('provider'));
                 throw new Zend_Controller_Action_Exception('Login failed');
             } else {
                 $this->_redirect('/index/connect');
             }
         } else {
             // Normal login page
             $this->view->googleAuthUrl = TBS\Auth\Adapter\Google::getAuthorizationUrl();
             $this->view->googleAuthUrlOffline = TBS\Auth\Adapter\Google::getAuthorizationUrl(true);
             $this->view->facebookAuthUrl = TBS\Auth\Adapter\Facebook::getAuthorizationUrl();
             // echo "sdd===>".TBS\Auth\Adapter\Facebook::getAuthorizationUrl();exit;
             //  $this->view->twitterAuthUrl = \TBS\Auth\Adapter\Twitter::getAuthorizationUrl();
         }
     }
 }
 public function loginAction()
 {
     $auth = TBS\Auth::getInstance();
     $providers = $auth->getIdentity();
     // Here the response of the providers are registered
     if ($this->_hasParam('provider')) {
         $provider = $this->_getParam('provider');
         switch ($provider) {
             case "facebook":
                 if ($this->_hasParam('code')) {
                     $adapter = new TBS\Auth\Adapter\Facebook($this->_getParam('code'));
                     $result = $auth->authenticate($adapter);
                 }
                 if ($this->_hasParam('error')) {
                     throw new Zend_Controller_Action_Exception('Facebook login failed, response is: ' . $this->_getParam('error'));
                 }
                 break;
             case "twitter":
                 if ($this->_hasParam('oauth_token')) {
                     $adapter = new TBS\Auth\Adapter\Twitter($_GET);
                     $result = $auth->authenticate($adapter);
                 }
                 break;
             case "google":
                 if ($this->_hasParam('code')) {
                     $adapter = new TBS\Auth\Adapter\Google($this->_getParam('code'));
                     $result = $auth->authenticate($adapter);
                 }
                 if ($this->_hasParam('error')) {
                     throw new Zend_Controller_Action_Exception('Google login failed, response is: ' . $this->_getParam('error'));
                 }
                 break;
         }
         // What to do when invalid
         if (isset($result) && !$result->isValid()) {
             $auth->clearIdentity($this->_getParam('provider'));
             throw new Zend_Controller_Action_Exception('Login failed');
         } else {
             $this->_redirect('/user/connect');
         }
     } else {
         // Normal login page
         $this->view->googleAuthUrl = TBS\Auth\Adapter\Google::getAuthorizationUrl();
         $this->view->googleAuthUrlOffline = TBS\Auth\Adapter\Google::getAuthorizationUrl(true);
         $this->view->facebookAuthUrl = TBS\Auth\Adapter\Facebook::getAuthorizationUrl();
         $this->view->twitterAuthUrl = \TBS\Auth\Adapter\Twitter::getAuthorizationUrl();
     }
 }
Example #3
0
 public function indexAction()
 {
     $model = new Users_Model_User();
     $namespace = new Zend_Session_Namespace('userInfo');
     $namespace->user_id = 17;
     $namespace->user_fname = 'Ankit';
     $namespace->user_lname = 'Sharma';
     $namespace->user_img = $img;
     if (!isset($_SESSION)) {
         $auth = TBS\Auth::getInstance();
         $providers = $auth->getIdentity();
         // Here the response of the providers are registered
         if ($this->_hasParam('provider')) {
             $provider = $this->_getParam('provider');
             switch ($provider) {
                 case "facebook":
                     if ($this->_hasParam('code')) {
                         $adapter = new TBS\Auth\Adapter\Facebook($this->_getParam('code'));
                         $result = $auth->authenticate($adapter);
                     }
                     if ($this->_hasParam('error')) {
                         throw new Zend_Controller_Action_Exception('Facebook login failed, response is: ' . $this->_getParam('error'));
                     }
                     break;
                 case "twitter":
                     if ($this->_hasParam('oauth_token')) {
                         $adapter = new TBS\Auth\Adapter\Twitter($_GET);
                         $result = $auth->authenticate($adapter);
                     }
                     break;
                 case "google":
                     if ($this->_hasParam('code')) {
                         $adapter = new TBS\Auth\Adapter\Google($this->_getParam('code'));
                         $result = $auth->authenticate($adapter);
                     }
                     if ($this->_hasParam('error')) {
                         throw new Zend_Controller_Action_Exception('Google login failed, response is: ' . $this->_getParam('error'));
                     }
                     break;
             }
             // What to do when invalid
             if (isset($result) && !$result->isValid()) {
                 $auth->clearIdentity($this->_getParam('provider'));
                 throw new Zend_Controller_Action_Exception('Login failed');
             } else {
                 $this->_redirect('/index/connect');
             }
         } else {
             // Normal login page
             $this->view->googleAuthUrl = TBS\Auth\Adapter\Google::getAuthorizationUrl();
             $this->view->googleAuthUrlOffline = TBS\Auth\Adapter\Google::getAuthorizationUrl(true);
             $this->view->facebookAuthUrl = TBS\Auth\Adapter\Facebook::getAuthorizationUrl();
             // echo "sdd===>".TBS\Auth\Adapter\Facebook::getAuthorizationUrl();exit;
             //  $this->view->twitterAuthUrl = \TBS\Auth\Adapter\Twitter::getAuthorizationUrl();
         }
     }
     //$locations = file_get_contents("",true);
     //prd($locations);
     $locations = 'http://pickfreedeal.com/laundrywala/api/public/locations';
     $curl = curl_init($locations);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $curl_response = curl_exec($curl);
     if ($curl_response === false) {
         $info = curl_getinfo($curl);
         curl_close($curl);
         //die('error occured during curl exec. Additioanl info: ' . var_export($info));
     }
     curl_close($curl);
     $decoded = json_decode($curl_response);
     $locations = array();
     foreach ($decoded->_embedded->location as $location) {
         $locations[] = $location->city_name . " " . $location->local_area_name;
     }
     $this->view->locations = $locations;
     /* Fetch Packages { */
     $packageModel = new Application_Model_PackagesMapper();
     $packages = $packageModel->getAllPackages();
     $this->view->packages = $packages;
     /* } Fetch Packages */
 }