Codeigniter ION-AUTH在同一电子邮件地址条目上未显示错误
我面临的一个问题是,当我试图更新我的电子邮件地址时,如果我添加了数据库中已经存在的新电子邮件,它应该会显示一个错误。但是它没有显示出来 代码返回错误消息。但是它没有在视图中显示它。我真的需要解决办法 我的ajax调用:Codeigniter ION-AUTH在同一电子邮件地址条目上未显示错误,codeigniter,ion-auth,Codeigniter,Ion Auth,我面临的一个问题是,当我试图更新我的电子邮件地址时,如果我添加了数据库中已经存在的新电子邮件,它应该会显示一个错误。但是它没有显示出来 代码返回错误消息。但是它没有在视图中显示它。我真的需要解决办法 我的ajax调用: $.ajax({ type: "POST", dataType: 'json', data: $('#info_form').serialize() + '&timezone=' + x + '&timezone_
$.ajax({
type: "POST",
dataType: 'json',
data: $('#info_form').serialize() + '&timezone=' + x + '&timezone_name=' + y,
url: '<?php echo site_url('profile/change_info')?>',
success: function (response) {
if (response.status == 'ok') {
manual_on(y);
clearState();
$('#bullet').removeClass("message-icon-on").addClass("message-icon");
$('.change').attr('data-id','1').html('Auto Detect Your Timezone: Off');
$('#profile_message').html(response.message);
$('#profile_message').children("p").addClass("type-ok").delay(4000).fadeOut(400).css('display', 'block');;
$('#email_label').html($('input[name=email]', '#info_edit').val());
$('#info_form')[0].reset();
switchToView();
return;
} else if (response.status == 'validation_error') {
var first_printed = false;
$.each(response.fields_statuses, function (field, value) {
if (value.status != 'ok' && !first_printed) {
$('#profile_message').html(value.message);
$('#profile_message').children("p").addClass("type-error").delay(4000).fadeOut(400).css('display', 'block');;
first_printed = true;
}
var input = $('input[name=' + field + ']', '#info_form');
show_input_validation(input, value);
});
return;
}
outputAjaxMessage('#register_message', response);
}
});
我的模型
public function update($id, array $data)
{
$this->trigger_events('pre_update_user');
$user = $this->user($id)->row();
$this->db->trans_begin();
if ($this->identity_column == 'email' && $this->email_check($email)) {
$this->set_error('account_creation_duplicate_email');
return FALSE;
} elseif ($this->identity_column == 'username' && $this->username_check($username)) {
$this->set_error('account_creation_duplicate_username');
return FALSE;
}
$data['auto_timezone']=0;// turning timezone auto detection off
if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) {
$this->db->trans_rollback();
$this->set_error('account_creation_duplicate_' . $this->identity_column);
$this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
$this->set_error('update_unsuccessful');
return FALSE;
}
// Filter the data passed
$data = $this->_filter_data($this->tables['users'], $data);
if (array_key_exists('username', $data) || array_key_exists('password', $data) || array_key_exists('email', $data) || array_key_exists('timezone', $data)) {
if (array_key_exists('password', $data)) {
if (!empty($data['password'])) {
$data['password'] = $this->hash_password($data['password'], $user->salt);
} else {
// unset password so it doesn't effect database entry if no password passed
unset($data['password']);
}
}
}
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array('id' => $user->id));
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
$this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
$this->set_error('update_unsuccessful');
return FALSE;
}
$this->db->trans_commit();
$this->trigger_events(array('post_update_user', 'post_update_user_successful'));
$this->set_message('update_successful');
return TRUE;
}
public function update($id, array $data)
{
$this->trigger_events('pre_update_user');
$user = $this->user($id)->row();
$this->db->trans_begin();
if ($this->identity_column == 'email' && $this->email_check($email)) {
$this->set_error('account_creation_duplicate_email');
return FALSE;
} elseif ($this->identity_column == 'username' && $this->username_check($username)) {
$this->set_error('account_creation_duplicate_username');
return FALSE;
}
$data['auto_timezone']=0;// turning timezone auto detection off
if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) {
$this->db->trans_rollback();
$this->set_error('account_creation_duplicate_' . $this->identity_column);
$this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
$this->set_error('update_unsuccessful');
return FALSE;
}
// Filter the data passed
$data = $this->_filter_data($this->tables['users'], $data);
if (array_key_exists('username', $data) || array_key_exists('password', $data) || array_key_exists('email', $data) || array_key_exists('timezone', $data)) {
if (array_key_exists('password', $data)) {
if (!empty($data['password'])) {
$data['password'] = $this->hash_password($data['password'], $user->salt);
} else {
// unset password so it doesn't effect database entry if no password passed
unset($data['password']);
}
}
}
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array('id' => $user->id));
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
$this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
$this->set_error('update_unsuccessful');
return FALSE;
}
$this->db->trans_commit();
$this->trigger_events(array('post_update_user', 'post_update_user_successful'));
$this->set_message('update_successful');
return TRUE;
}