Skip to content

Instantly share code, notes, and snippets.

@orourkek
Created June 7, 2012 18:33
Show Gist options
  • Save orourkek/12e5d6d8898b736af9d7 to your computer and use it in GitHub Desktop.
Save orourkek/12e5d6d8898b736af9d7 to your computer and use it in GitHub Desktop.
public function login()
{
$this->enforce_loggedout();
$data['content_data']['error_state'] = false;
$data['content_data']['form_action'] = '';
if($this->input->post('login-submit') !== false)
{ #login form was submitted, check the data
$un = $this->input->post('username');
$pw = $this->input->post('password');
if(!$un || !$pw)
{
$data['content_data']['error_state'] = true;
}
else
{
$loginResult = $this->sslogin->login($un, $pw);
if($loginResult === false)
{
$data['content_data']['error_state'] = true;
$data['content_data']['username'] = $un;
}
}
if($data['content_data']['error_state'] === false)
{ #redirect them back away, successful login!
if($this->input->post('orig_referer'))
{
redirect($this->input->post('orig_referer'), 'location');
}
redirect('', 'location');
}
}
//show the login page
$data['header_data']['title'] = 'Login';
$data['header_data']['navActive'] = null;
$data['header_data']['userbar'] = $this->userbar->init();
$data['content_view'] = 'account/login';
$this->load->view('master', $data);
}
/* Pseudocode:
Login form submitted?
yes: validate form data
data valid?
yes: redirect
no: continue
no: continue
show the login page
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment