function change_password() { if ($this->input->post('user_id') && $this->input->post('user_login_password') && $this->input->post('user_confirm_password')) { $this->load->library('form_validation'); $this->form_validation->set_rules('user_login_password', 'Password', 'trim|required|min_length[5]'); $this->form_validation->set_rules('user_confirm_password', 'Confirm Password ', 'trim|required|matches[user_login_password]'); if ($this->form_validation->run()) { $time_now = date('Y-m-d H:i:s'); $this->load->library('encrypt'); $user_details_array = array('user_login_salt' => md5($time_now), 'user_login_password' => md5(md5(md5($time_now) . $this->input->post('user_login_password'))), 'user_password_hash' => $this->encrypt->encode($this->input->post('user_login_password'), md5(md5(md5($time_now) . $this->input->post('user_login_password')))), 'user_security_hash' => md5($time_now . $this->input->post('user_login_password')), 'force_change_password' => '1', 'user_modified' => $time_now); if ($this->User_model->edit($this->input->post('user_id'), $user_details_array)) { if ($this->input->post('notify_user') && $this->input->post('notify_user') === '1') { $user_array = $this->User_model->get_user_by_id($this->input->post('user_id')); $this->load->helper('string'); $email_hash = random_string('unique'); $email_body = parent::add_email_tracking($email_hash, $this->render_view(array('email_hash' => $email_hash, 'user_first_name' => $user_array['user_first_name'], 'user_last_name' => $user_array['user_last_name'], 'user_login_password' => $this->input->post('user_login_password'), 'login_link' => base_url() . 'auth/login'), 'emails', 'emails/users_change_password', TRUE)); if (parent::send_email($email_hash, 'Password Changed Notification', $this->config->item('email_from'), $user_array['user_email'], $email_body)) { die('1'); } else { die('Error Sending Email !!!'); } } else { die('1'); } } } else { echo validation_errors(); die; } } die('0'); }
function google() { $this->load->library('Google_api'); $user_profile = $this->google_api->login($this->uri->uri_string); if (isset($user_profile->email)) { $this->load->model('Auth_model'); $user_details_array = $this->Auth_model->login($user_profile->email); if (count($user_details_array) > 0) { if ($user_details_array['user_google_id'] === '') { $this->load->model('User_model'); $this->User_model->edit($user_details_array['user_id'], array('user_google_id' => $user_profile->id)); $user_details_array['user_facebook_id'] = $user_profile->id; } $userdata = $this->session->all_userdata(); $_SESSION['user'] = $user_details_array; $this->Auth_model->update_user_login($user_details_array['user_id']); if (isset($userdata['redirect_uri']) && $userdata['redirect_uri'] != '') { $this->session->unset_userdata('redirect_uri'); redirect($userdata['redirect_uri'], 'refresh'); } redirect('auth/dashboard', 'refresh'); } else { $time_now = date('Y-m-d H:i:s'); $this->load->library('encrypt'); $user_details_array = array('user_google_id' => $user_profile->id, 'user_first_name' => $user_profile->givenName, 'user_last_name' => $user_profile->familyName, 'user_email' => $user_profile->email, 'user_login' => '', 'user_login_salt' => md5($time_now), 'user_login_password' => md5(md5(md5($time_now) . $user_profile->id)), 'user_password_hash' => $this->encrypt->encode($user_profile->id, md5(md5(md5($time_now) . $user_profile->id))), 'user_security_hash' => md5($time_now . $user_profile->id), 'newsletter_status' => '1', 'groups_id' => '3', 'user_status' => '1', 'user_created' => $time_now); if ($user_profile->gender === 'female') { $user_details_array['user_gender'] = '0'; } else { if ($user_profile->gender === 'male') { $user_details_array['user_gender'] = '1'; } else { $user_details_array['user_gender'] = '-1'; } } if ($this->Auth_model->create_account($user_details_array)) { $this->load->helper('string'); $email_hash = random_string('unique'); $email_body = parent::add_email_tracking($email_hash, $this->render_view(array('email_hash' => $email_hash, 'user_first_name' => $user_details_array['user_first_name'], 'user_last_name' => $user_details_array['user_last_name'], 'users_profile' => base_url() . 'users/profile'), 'emails', 'emails/google_signup', TRUE)); if (parent::send_email($email_hash, 'Welcome ' . $user_details_array['user_first_name'] . ' ' . $user_details_array['user_last_name'], $this->config->item('email_from'), $user_details_array['user_email'], $email_body)) { $user_details_array = $this->Auth_model->login($user_profile->email); if (count($user_details_array) > 0 && isset($user_details_array['user_google_id']) && $user_details_array['user_google_id'] !== '') { $userdata = $this->session->all_userdata(); $_SESSION['user'] = $user_details_array; $this->Auth_model->update_user_login($user_details_array['user_id']); if (isset($userdata['redirect_uri']) && $userdata['redirect_uri'] != '') { $this->session->unset_userdata('redirect_uri'); redirect($userdata['redirect_uri'], 'refresh'); } redirect('auth/dashboard', 'refresh'); } } } } redirect('auth/logout'); } }