संपादित मैं के नवीनतम संस्करण CodeIgniter 2 के साथ साथ नवीनतम आयन प्रमाणीकरण फ़ाइलों का उपयोग कर रहा हूँ।CodeIgniter 2 और आयन प्रमाणीकरण - खुद उपयोगकर्ता खाते
नियंत्रक फ़ाइल के भीतर edit_user
नामक एक फ़ंक्शन है। यह समारोह "व्यवस्थापक" समूह के भीतर सदस्यों द्वारा ही उपयोग करने के लिए प्रतिबंधित है, और किसी भी व्यवस्थापक सदस्य किसी भी अन्य सदस्य इस URL के माध्यम से समारोह का उपयोग कर संपादित कर सकते हैं ...
/auth/edit_user/id
समस्या यह है कि मैं डॉन 'है कोई कंट्रोलर फ़ंक्शन या व्यू देखें जो एक नियमित (गैर-व्यवस्थापक) उपयोगकर्ता को संपादित करने की अनुमति देता है, जो उनके खाता विवरण संपादित करता है।
क्या यह एक नया कंट्रोलर फ़ंक्शन होगा जो मुझे लिखने की आवश्यकता होगी (edit_user
फ़ंक्शन संशोधित करें?) या यह ऐसा कुछ है जो आयन औथ पहले से ही करना चाहिए? यदि हां, तो कैसे?
यहाँ शेयर आयन प्रमाणीकरण edit_user
समारोह auth.php
नियंत्रक के भीतर निहित ...
function edit_user($id)
{
$this->data['title'] = "Edit User";
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
{
redirect('auth', 'refresh');
}
$user = $this->ion_auth->user($id)->row();
//process the phone number
if (isset($user->phone) && !empty($user->phone))
{
$user->phone = explode('-', $user->phone);
}
//validate form input
$this->form_validation->set_rules('first_name', 'First Name', 'required|xss_clean');
$this->form_validation->set_rules('last_name', 'Last Name', 'required|xss_clean');
$this->form_validation->set_rules('phone1', 'First Part of Phone', 'required|xss_clean|min_length[3]|max_length[3]');
$this->form_validation->set_rules('phone2', 'Second Part of Phone', 'required|xss_clean|min_length[3]|max_length[3]');
$this->form_validation->set_rules('phone3', 'Third Part of Phone', 'required|xss_clean|min_length[4]|max_length[4]');
$this->form_validation->set_rules('company', 'Company Name', 'required|xss_clean');
if (isset($_POST) && !empty($_POST))
{
// do we have a valid request?
if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id'))
{
show_error('This form post did not pass our security checks.');
}
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'company' => $this->input->post('company'),
'phone' => $this->input->post('phone1') . '-' . $this->input->post('phone2') . '-' . $this->input->post('phone3'),
);
//update the password if it was posted
if ($this->input->post('password'))
{
$this->form_validation->set_rules('password', 'Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
$this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required');
$data['password'] = $this->input->post('password');
}
if ($this->form_validation->run() === TRUE)
{
$this->ion_auth->update($user->id, $data);
//check to see if we are creating the user
//redirect them back to the admin page
$this->session->set_flashdata('message', "User Saved");
redirect("auth", 'refresh');
}
}
//display the edit user form
$this->data['csrf'] = $this->_get_csrf_nonce();
//set the flash data error message if there is one
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
//pass the user to the view
$this->data['user'] = $user;
$this->data['first_name'] = array(
'name' => 'first_name',
'id' => 'first_name',
'type' => 'text',
'value' => $this->form_validation->set_value('first_name', $user->first_name),
);
$this->data['last_name'] = array(
'name' => 'last_name',
'id' => 'last_name',
'type' => 'text',
'value' => $this->form_validation->set_value('last_name', $user->last_name),
);
$this->data['company'] = array(
'name' => 'company',
'id' => 'company',
'type' => 'text',
'value' => $this->form_validation->set_value('company', $user->company),
);
$this->data['phone1'] = array(
'name' => 'phone1',
'id' => 'phone1',
'type' => 'text',
'value' => $this->form_validation->set_value('phone1', $user->phone[0]),
);
$this->data['phone2'] = array(
'name' => 'phone2',
'id' => 'phone2',
'type' => 'text',
'value' => $this->form_validation->set_value('phone2', $user->phone[1]),
);
$this->data['phone3'] = array(
'name' => 'phone3',
'id' => 'phone3',
'type' => 'text',
'value' => $this->form_validation->set_value('phone3', $user->phone[2]),
);
$this->data['password'] = array(
'name' => 'password',
'id' => 'password',
'type' => 'password'
);
$this->data['password_confirm'] = array(
'name' => 'password_confirm',
'id' => 'password_confirm',
'type' => 'password'
);
$this->load->view('auth/edit_user', $this->data);
}
इसे स्वयं जवाब देने और कोड पोस्ट करने के लिए धन्यवाद। मैंने इसे पुल अनुरोध के रूप में पोस्ट किया और अब इसे आयन ऑथ रिपोजिटरी में विलय कर दिया गया है। – tagawa