Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]dhaulagiri[/eluser]
when creating new controller with this auth, what should i include for checking login ? What should i load in constructor ?

Is this enough ?



Code:
function __Construct()
{
parent::Controller();
$this->load->library(ion_auth);
//what to include for check login

//is there anything else i should add in constructor fpr best practise ?
}

OK i did this and it seems to be working, can i implement this in live site ? I really like this auth.


Code:
function __Construct()
{
parent::Controller();
$this->load->library(ion_auth);
if(!this->ion_auth->logged_in()) redirect('auth/login');

//is there anything else i should add in constructor fpr best practise ?
}

[eluser]Ben Edmunds[/eluser]
dhaulagiri,

This code should be fine, notice the small changes I made:


Code:
function __construct()
{
parent::Controller();
$this->load->library('ion_auth');
if(!this->ion_auth->logged_in()) redirect('auth/login');

[eluser]dhaulagiri[/eluser]
Thank you so much ben , I think you change 'C' to lowercase, does it matter ?

[eluser]dhaulagiri[/eluser]
Is it possible to have 2 view files from one controller one for public page and another for admin page ( after applying ion auth)?

[eluser]Ben Edmunds[/eluser]
dhaulagiri,

I changed the case on the C and added single quotes to your method calls.

Yea you can definitely do that.

Something like this:

Code:
if ($this->ion_auth->is_admin()) {
   $this->load->view('admin', $data)
}
else {
   $this->load->view('public', $data)
}

[eluser]Pokhara[/eluser]
How to set permission on groups in this auth ? Can groups be added dynamically ?

[eluser]Ben Edmunds[/eluser]
Pokhara,

You have to manually set the permissions by checking the group. Yes you can dynamically add groups.

This is not a full on ACL system. This is just a simple, lightweight, auth system. So if you need complex ACL you should probably use a different library.

[eluser]Pokhara[/eluser]
Code:
$this->ion_auth->get_user();

this is not helping to echo group or user in header section, not even after attaching isset.

[eluser]joytopia[/eluser]
Pokhara,
you have to use the result-function:
Code:
$result = $this->ion_auth_model->get_user($id);      
       $this->uso = $result->row();
       $this->usa = $result->row_array();

[eluser]Ben Edmunds[/eluser]
Pokhara, Bernd,

If you use $this->ion_auth->get_user() or will return an object of the currently logged in user. You won't get anything though if there is no user logged in.

You can also pass it a user id if you want to get a specific user, $this->ion_auth->get_user($id).




Theme © iAndrew 2016 - Forum software by © MyBB