public function oauth() { $adapter_id = $this->request->get['oa2_adapter']; $oauth_verification = !empty($this->request->get['oauth_verifier']); if ($adapter_id === 'twitter') { try { $this->initOauth(); $oauth = new TwitterOAuth($this->getConfig('twt_consumer_key'), $this->getConfig('twt_consumer_secret')); if ($oauth_verification) { $access_token = $oauth->getAccessToken($this->request->get['oauth_verifier'], $this->request->get['oauth_token']); $profile = $oauth->profile(array('skip_status' => true)); if (!empty($profile->errors)) { $this->vars['error'] = true; $this->vars['success'] = false; $this->vars['message'] = $profile->errors[0]->message; return $this->out(); } $logged = array(OAuth2_Consts::CUSTOMER_DISPLAYNAME => $profile->screen_name, OAuth2_Consts::CUSTOMER_FIRSTNAME => $profile->name, OAuth2_Consts::CUSTOMER_EXT_ID => $profile->id_str); $user = $this->createCustomerAndLogin(array(), $logged); if (!$user || !$this->customer->isLogged()) { $this->vars['error'] = true; $this->vars['success'] = false; $this->vars['message'] = $this->language->get('error_retry'); } else { $this->vars['success'] = true; $this->vars['message'] = $this->language->get('success_login'); $this->vars['redirect'] = isset($this->session->data['redirect']) ? $this->session->data['redirect'] : $this->url->link('account/account'); } } else { $oauth_callback = $this->url->link('account/social_media_login/oauth', 'oa2_adapter=twitter'); $request_token = $oauth->getRequestToken($oauth_callback); $authorize_url = $oauth->getAuthorizeURL($request_token); $this->response->redirect($authorize_url); } } catch (Exception $e) { $this->logException($e); $this->vars['error'] = true; $this->vars['success'] = false; $this->vars['message'] = $this->language->get('error_retry'); } } return $this->out(); }