[eluser]austintbiggs[/eluser]
So after making countless little changes I'm curious if I broke it or at least how to fix it? I'm finding problems with not displaying error messages as well as adding new users. It's probably something stupid I did, lol. But maybe someone can figure it out?
Auth.php
Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! class_exists('Controller'))
{
class Controller extends CI_Controller {}
}
class Auth extends Controller {
function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->library('session');
$this->load->library('form_validation');
$this->load->database();
$this->load->helper('url');
// $this->load->driver('minify');
}
//redirect if needed, otherwise display the user list
function index()
{
if (!$this->ion_auth->logged_in())
{
//redirect them to the login page
redirect('auth/login', 'refresh');
}
else
{
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
//list the users
$this->data['users'] = $this->ion_auth->get_users_array();
$this->load->view('auth/index', $this->data);
}
}
//log the user in
function login()
{
$this->data['title'] = "Login";
//validate form input
$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
$this->form_validation->set_rules('password', 'Password', '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('email'), $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($this->config->item('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', '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['email'] = array('name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email')
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password'
);
$this->load->view('auth/login', $this->data);
}
}
//log the user out
function logout()
{
$this->data['title'] = "Logout";
//log the user out
$logout = $this->ion_auth->logout();
//redirect them back to the page they came from
redirect('auth', 'refresh');
}