Exemple #1
0
 function _add_facebook($uuid)
 {
     if (!empty($_SERVER['QUERY_STRING'])) {
         parse_str($_SERVER['QUERY_STRING'], $_GET);
         if (!empty($_GET['code'])) {
             $token = process_facebook_verification($_GET['code'], site_url("user/identities/{$uuid}/add_facebook"));
             $fb_id = facebook_get_id($this, $token);
             if (!$this->sg_auth->facebook_exists($fb_id)) {
                 if (!$this->simiangrid->identity_set($uuid, 'facebook', $fb_id)) {
                     push_message(lang('sg_auth_fb_error_assoc'), 'error');
                 }
             }
         }
     }
     return redirect("user/view/{$uuid}");
 }
 function register_facebook()
 {
     if (!$this->sg_auth->is_logged_in() && $this->sg_auth->allow_registration) {
         $token = $this->_get_facebook_token();
         if ($token == null) {
             return redirect('auth/register');
         }
         $token = $this->_get_facebook_token();
         if ($token == null) {
             push_message(lang('sg_auth_fb_error'), 'error');
             return redirect('auth/register');
         }
         $fb_id = facebook_get_id($this, $token);
         if ($fb_id == null) {
             push_message(lang('sg_auth_fb_error'), 'error');
             return redirect('auth/register');
         }
         if (!$this->sg_auth->facebook_exists($fb_id) && facebook_check($this, $token, $data)) {
             $val = $this->form_validation;
             $user_id = $this->_register($val);
             if ($user_id === null) {
                 push_message(lang('sg_auth_register_failure'), 'error');
                 return redirect('auth/register');
             } else {
                 if ($user_id !== FALSE) {
                     if ($this->simiangrid->identity_set($user_id, 'facebook', $fb_id)) {
                         return redirect('about');
                     } else {
                         push_message(lang('sg_auth_fb_error_assoc'), 'error');
                         $this->simiangrid->user_delete($user_id);
                     }
                 } else {
                     // Load OpenID registrationpage
                     $data['page'] = 'join';
                     return parse_template('auth/register_facebook', $data);
                 }
             }
         }
     } elseif (!$this->sg_auth->allow_registration) {
         push_message(lang('sg_auth_registration_disabled'), 'error');
     } else {
         push_message(lang('sg_auth_error_logout_first'), 'error');
     }
     return redirect('about');
 }