Esempio n. 1
0
 public function index()
 {
     $this->load->model('account/socl_login');
     if (!$this->model_account_socl_login->checkInstalled() || !isset($this->request->get['token'])) {
         if (!$this->customer->isLogged()) {
             $this->session->data['redirect'] = $this->url->link('account/account', '', 'SSL');
             $this->load->language('account/socl_login');
             $this->response->redirect($this->url->link('account/login', "soclerror=" . $this->language->get('error_cant_get_token'), 'SSL'));
         }
     }
     $token = $this->request->get['token'];
     $socl_all = new SoclAll($this->config->get('soclall_appid'), $this->config->get('soclall_secretkey'));
     $user = $socl_all->getUser($token);
     if (isset($user['error'])) {
         $this->response->redirect($this->url->link('account/login', "soclerror=" . $user['error'], 'SSL'));
     }
     if (isset($user['success'])) {
         $user = $user['result'];
         $soclall_id = $this->request->get['network'] == 'tumblr' ? $user['profile_url'] : $user['id'];
     }
     if (isset($soclall_id) && !empty($soclall_id) && isset($this->request->get['network'])) {
         $email = $this->model_account_socl_login->checkSoclCustomerById($soclall_id, $this->request->get['network']);
         if ($email) {
             if ($this->loginSocl($email)) {
                 $this->response->redirect($this->url->link('account/account', '', 'SSL'));
             } else {
                 $this->response->redirect($this->url->link('account/login', "soclerror=" . $this->error['warning'], 'SSL'));
             }
         }
         if (!empty($user['email'])) {
             if ($this->model_account_socl_login->checkSoclCustomerByEmail($user['email'])) {
                 $this->model_account_socl_login->insertUpdateNewSoclId($soclall_id, $user['email'], $this->request->get['network']);
                 if ($this->loginSocl($user['email'])) {
                     $this->response->redirect($this->url->link('account/account', '', 'SSL'));
                 } else {
                     $this->response->redirect($this->url->link('account/login', "soclerror=" . $this->error['warning'], 'SSL'));
                 }
             }
         }
         $params = "soclid=" . $soclall_id . "&network=" . $this->request->get['network'];
         if (!empty($user['email'])) {
             $params .= "&email=" . $user['email'];
         }
         if (!empty($user['first_name'])) {
             $params .= "&firstname=" . $user['first_name'];
         }
         if (!empty($user['last_name'])) {
             $params .= "&lastname=" . $user['last_name'];
         }
         $this->response->redirect($this->url->link('account/login', $params, 'SSL'));
     } else {
         $this->load->language('account/socl_login');
         $this->response->redirect($this->url->link('account/login', "soclerror=" . $this->language->get('error_get_user_fail'), 'SSL'));
     }
 }
Esempio n. 2
0
 public function getSoclLoginList()
 {
     $socl_login = array();
     if ($this->config->get('soclall_appid') && $this->config->get('soclall_secretkey')) {
         $this->load->model('tool/image');
         $socl_all = new SoclAll($this->config->get('soclall_appid'), $this->config->get('soclall_secretkey'));
         $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "soclall_network`");
         if ($query->num_rows) {
             $enabled_net = $this->config->get('soclall_enabled_network');
             foreach ($query->rows as $network) {
                 if (is_array($enabled_net) && in_array($network['network_code'], $enabled_net)) {
                     $socl_login[] = array('href' => $socl_all->getLoginUrl($network['network_code'], $this->url->link('account/socl_login', '', 'SSL')), 'icon' => $this->model_tool_image->resize("data/social_all/" . $network['logo'], 32, 32), 'alt_text' => $network['network_name']);
                 }
             }
         }
     }
     return $socl_login;
 }