Skip to content

PedroRuiz/CodeIgniterLoginControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CodeIgniterLoginControl

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());
			
			$this->load->add_package_path(APPPATH.'third_party/login_control');
			$this->load->model('login_control');
			$this->login_control->write_login($this->ion_auth->user()->row()->id);
			
			redirect(base_url(), 'refresh');
		}
		else
		{
			// 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
		}
	}
	else
	{
		// 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.

About

Login Control for Ben Edmund's Ion_Auth

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages