@design_shuffle check this out
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
February 10, 2010 7:00pm
Subscribe [287]#511 / Aug 11, 2010 6:24am
@design_shuffle check this out
#512 / Aug 11, 2010 3:43pm
Thinking about my previous changes, and how about if an user is logged and we change his group or deactivate him. The lib is just checking the group and the user id stored in the session, so, while the session doesn’t finishes, he will stay with the active and within the group that he was when he logged in.
what do you think about it?
One solution would be set the ci session expiration time with a short value, like 30 min, or 1 hour. Then, if he marked the “remember” option, when the login_remembered_user function run, it will remake the group and the active status with my previous post modification…
Another solution would be check if he’s active and the group every time we run “is_group” or “logged_in”. But I think it’s not too good, cause it would have too many selects, and if we have some hundreds of users or a bad server it would slow down the app…
What do you think?
Sadly, I don’t have access to github. I’d really like to help more…
thanks.
#513 / Aug 11, 2010 4:44pm
My final solution to this was:
in the ion_auth model I created this methods:
public function check_session_validity()
{
$this->db->where($this->tables['users'].'.id', $this->session->userdata('user_id'));
$this->db->where($this->tables['users'].'.'.$this->identity_column, $this->session->userdata($this->identity_column));
$this->db->where($this->tables['users'].'.group_id', $this->session->userdata('group_id'));
$this->db->where($this->tables['users'].'.active', 1);
return $this->db->count_all_results($this->tables['users']) > 0;
}
public function refresh_session_data(){
$db_user_data = $this->get_user()->row();
if(empty($db_user_data)){
return FALSE;
}
if($db_user_data->active == 0){
return FALSE;
}
$this->session->set_userdata($this->identity_column, $db_user_data->{$this->identity_column});
$this->session->set_userdata('group_id', $db_user_data->group_id);
$this->session->set_userdata('group', $db_user_data->group);
return TRUE;
}
and in the constructor of the library, after check remembered, I put this code
//auto-login the user if they are remembered
if (!$this->logged_in() && get_cookie('identity') && get_cookie('remember_code'))
{
$this->ci->ion_auth_model->login_remembered_user();
}
//check if the data in the session is equal to database data
elseif($this->logged_in() && !$this->ci->ion_auth_model->check_session_validity())
{
//try to refresh the session data
if(! $this->ci->ion_auth_model->refresh_session_data()){
//oh, I can't update the session. Probably the user was deactivated
$this->logout();
}
}What do you think?
As I said, I don’t have access to github, but I’ll try to get this friday at home…
#514 / Aug 12, 2010 12:28am
Did you couple that code with a timeout value so as not to overload the db with calls?
#515 / Aug 12, 2010 12:47am
Hey Ben, it turned out to be a very simple. $this->form_validation->run() always returned false because of how you loaded the ‘login’ view.
if (!$this->ion_auth->logged_in()) {
//redirect them to the login page
redirect('auth/login', 'refresh');
}Using $this->load->view(‘auth/login’, ‘refresh’); solved the problem for me.
Your example controller & views just didn’t work right out the box for me. The other forms are broken, too, but solved in a similar fashion.
And thank you for writing this beautiful authentication library. =]
#516 / Aug 12, 2010 8:50am
Did you couple that code with a timeout value so as not to overload the db with calls?
The problem with change the session timeout is that if an user doesn’t check “remember me”, he will disconnect when the session reachs the timeout. An another problem is that if I need to deactivate an user that is logged, he will stay logged in until the session expire. And the same problem if I change the user group.
Like I’m just doing a count, I don’t think it will be a problem. Another solution?
#517 / Aug 15, 2010 9:53pm
You would use another “timeout” value(one specific to this requirement) and tuck it into the SESSION variable. So that if it is 1 hour, every one hour you check the db to see if the user is still enabled.
#518 / Aug 16, 2010 1:47pm
Hmm, now I understood you. It’s a good idea too, but the problem with “in real time” blocking will still bothering me 😛
It’s a requirement of my app, so… I think that some counts won’t make me lose my sleep… Thank you very much.
#519 / Aug 17, 2010 1:07am
@Lucas… I don’t know enough about sessions (which is why I use Ion Auth), but is it possible to delete/destroy a users session whenever their group is changed and/or they are de-activated?
If this can be done, then upon changing their group, they would be automatically logged out and have to login again.
#520 / Aug 17, 2010 1:18am
Looking for comments on ACL for CRUD ... My next application will require Access Control for Create Read Update Delete for each user on each page.
I really like Ion Auth, and wanted to brainstorm with everybody’s comments/ideas on how to modify it to work in such a scenario. The ultimate goal would be to come up with a solution that is still “lightweight” enough to have the code actually included as part of Ion Auth. If it gets a little too “heavy” then alternatively it could become it’s own library that uses Ion Auth as it’s base.
I am no expert when it comes to Authorization and Access Control so all pointers would be helpful!
Thanks
Jeff
#521 / Aug 17, 2010 8:46am
@jsherk ... To do this, you need to compare the session with the db, what will fall in the same question…
thanks
#522 / Aug 17, 2010 9:04am
@Lucas ... I thought my answer was too obvious!
#523 / Aug 18, 2010 9:41am
Look at UNIX Permissions hint
InsiteFX
#524 / Aug 20, 2010 5:38pm
I am having an issue with changing user passwords,
Here is the snippet I’m using to do so:
$password = $this->input->post('password');
$data = array(
'password' => $password
);
print_r($data);
$this->ion_auth->update_user($id,$data);I am getting this error:
A Database Error Occurred
You must use the "set" method to update an entry.and when I print_r($data), I get this:
Array ( [password] => whateverpasswordItyped )am I missing something? I thought there was a change_password function, but I couldn’t find it in the docs.
#525 / Aug 20, 2010 6:03pm
You could use the function change_password($identity, $old, $new)...
You just need to pass the identity from who you want to change the password, the old password and the new password…