示例#1
0
 function _add_openid($uuid)
 {
     $callback_url = site_url("user/identities/{$uuid}/add_openid");
     if ($this->input->post('action') == 'verify') {
         return openid_process_verify($this, $callback_url);
     } else {
         if ($this->session->flashdata('openid_identifier') or openid_check($this, $callback_url, $data)) {
             $openid = null;
             if ($this->session->flashdata('openid_identifier')) {
                 $openid = $this->session->flashdata('openid_identifier');
                 $data['openid_identifier'] = $openid;
                 $this->session->keep_flashdata('openid_identifier');
             } else {
                 $openid = $data['openid_identifier'];
                 $this->session->set_flashdata('openid_identifier', $openid);
             }
             if (!$this->sg_auth->openid_exists($openid)) {
                 if (!$this->simiangrid->identity_set($uuid, 'openid', $openid)) {
                     push_message(lang('sg_auth_open_error_assoc'), 'error');
                 }
             }
         }
     }
     return redirect("user/view/{$uuid}/identities");
 }
 function register_openid()
 {
     if (!$this->sg_auth->is_logged_in() && $this->sg_auth->allow_registration) {
         $data = array();
         if ($this->input->post('action') == 'verify') {
             return openid_process_verify($this, site_url('auth/register_openid'));
         } else {
             if ($this->session->flashdata('openid_identifier') or openid_check($this, site_url('auth/register_openid'), $data)) {
                 $openid = null;
                 if ($this->session->flashdata('openid_identifier')) {
                     $openid = $this->session->flashdata('openid_identifier');
                     $data['openid_identifier'] = $openid;
                     $this->session->keep_flashdata('openid_identifier');
                 } else {
                     $openid = $data['openid_identifier'];
                     $this->session->set_flashdata('openid_identifier', $openid);
                 }
                 if (!$this->sg_auth->openid_exists($openid)) {
                     // OpenID authentication succeeded
                     $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, 'openid', $openid)) {
                                 return redirect('about');
                             } else {
                                 push_message(lang('sg_auth_open_error_assoc'), 'error');
                                 $this->simiangrid->user_delete($user_id);
                             }
                         } else {
                             // Load OpenID registration page
                             $data['page'] = 'join';
                             return parse_template('auth/register_openid', $data);
                         }
                     }
                 }
             } else {
                 return redirect('auth/register');
             }
         }
     } 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');
 }