[eluser]123wesweat[/eluser]
Hi,
I am having a problem with my logic. Somehow there is a new row added in the user_profile table when i logout and login again.
I do have an update method which triggers set_profile($user_id, $data). But this function updates a row it doesn't add a row, right??
Which function adds a row in table user_profile with the same user_id??? Only create_profile, right?? I don't trigger create_profile in my login logic>
The login method looks like
Code:
function login()
{
if ( ! $this->dx_auth->is_logged_in())
{
$val = $this->form_validation;
// Set form validation rules
$val->set_rules('username', 'Username', 'trim|required|xss_clean');
$val->set_rules('password', 'Password', 'trim|required|xss_clean');
$val->set_rules('remember', 'Remember me', 'integer');
//change some error messages
$val->set_message('required', '%s is verplicht');
// Set captcha rules if login attempts exceed max attempts in config
if ($this->dx_auth->is_max_login_attempts_exceeded())
{
$val->set_rules('captcha', 'Confirmation Code', 'trim|required|xss_clean|callback_captcha_check');
}
if ($val->run() AND $this->dx_auth->login($val->set_value('username'), $val->set_value('password'), $val->set_value('remember')))
{
//personal page
$this->load->model('dx_auth/user_profile');
$data['user_name'] = $this->dx_auth->get_username('username');
$user_id = $this->dx_auth->get_user_id('username');
$arrEmail=$this->_get_email($user_id);
$user_profile_data = $this->user_profile->get_profile($user_id)->result();
$data['profile_data'] = $user_profile_data[0];
$data['email'] = $arrEmail->email;
$data['auth_message'] = 'You are logged in.';
$this->load->view($this->dx_auth->logged_in_view, $data);
}
else
{
// Check if the user is failed logged in because user is banned user or not
if ($this->dx_auth->is_banned())
{
// Redirect to banned uri
$this->dx_auth->deny_access('banned');
}
else
{
// Default is we don't show captcha until max login attempts eceeded
$data['show_captcha'] = FALSE;
// Show captcha if login attempts exceed max attempts in config
if ($this->dx_auth->is_max_login_attempts_exceeded())
{
// Create catpcha
$this->dx_auth->captcha();
// Set view data to show captcha on view file
$data['show_captcha'] = TRUE;
}
$data['main_content'] = 'authFS/login_form';
$this->load->view('authFS/incs/template', $data);
}
}
}
else
{ //already loggedin
//load the profile page
$this->load->model('dx_auth/user_profile');
$data['user_name'] = $this->dx_auth->get_username('username');
$user_id = $this->dx_auth->get_user_id('username');
$arrEmail=$this->_get_email($user_id);
$user_profile_data = $this->user_profile->get_profile($user_id)->result();
//print_r($user_profile_data);
$data['profile_data'] = $user_profile_data[0];
$data['email'] = $arrEmail->email;
$data['auth_message'] = 'You are logged in.';
$this->load->view($this->dx_auth->logged_in_view, $data);
}
}
Any suggestions?