Login Control for Ben Edmund's Ion_Auth
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This login control run in CodeIgniter's application/third_party.

To install it, just copy all directories in third_party. Then move or copy controllers/Login.php to application/controllers and migrations/002_install_login_control.php to application/migrations/,obviusly do it with your app's right name of file.

In application/Auth.php set the login function like this. /**

public function login()
	$this->data['title'] = $this->lang->line('login_heading');

	// validate form input
	$this->form_validation->set_rules('identity', str_replace(':', '', $this->lang->line('login_identity_label')), 'required');
	$this->form_validation->set_rules('password', str_replace(':', '', $this->lang->line('login_password_label')), 'required');

	if ($this->form_validation->run() === TRUE)
		// check to see if the user is logging in
		// check for "remember me"
		$remember = (bool)$this->input->post('remember');

		if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
			//if the login is successful
			//redirect them back to the home page
			$this->session->set_flashdata('message', $this->ion_auth->messages());
			redirect(base_url(), 'refresh');
			// if the login was un-successful
			// redirect them back to the login page
			$this->session->set_flashdata('message', $this->ion_auth->errors());
			redirect('auth/login.html', 'refresh'); // use redirects instead of loading views for compatibility with MY_Controller libraries
		// the user is not logging in so display the login page
		// set the flash data error message if there is one
		$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

		$this->data['identity'] = array('name' => 'identity',
			'id' => 'identity',
			'type' => 'text',
			'value' => $this->form_validation->set_value('identity'),
		$this->data['password'] = array('name' => 'password',
			'id' => 'password',
			'type' => 'password',

		$this->_render_page('auth/login', $this->data);



That's all. Enjoy.