I have a controller for my front end, and I'm using the DX Auth lib.
I want to use DX Auth's registration, but include it in my front page controller...I can simply copy-paste the function, but is there a better way to do this?
I have a controller for my front end, and I'm using the DX Auth lib.
I want to use DX Auth's registration, but include it in my front page controller...I can simply copy-paste the function, but is there a better way to do this?
Are you trying to login and register users in your front page controller? You will need to install DX Auth according to the installation instructions and consult some of the examples and function references in the manual.
You'll need to load the DX Auth library in your constructor:
class Auth extends Controller
{
function Auth()
{
parent::Controller();
// Load library
$this->load->library('DX_Auth');
$this->load->library('Form_validation');
}
// implement other login functions like the examples
// using the library:
function login()
{
if (!$this->dx_auth->is_logged_in()) {
$is_valid = $this->form_validation->run('login');
$username = $this->input->post('username');
$password = $this->input->post('password');
if ($is_valid && $this->dx_auth->login($username, $password)) {
// redirect somewhere
} else {
// show some errors
}
}
}
// other authentication functions
}
If you wanted to you could make a helper to hold your authentication functions so you could access them from any controller. Follow the installation instructions to get your database set up and some sort of basic user registration and login working--they are fairly comprehensive.