Thanks Ben,
Just to be clear, it’s located in the Ion Auth model, right? (I’ve substituted it for a bcrypt implementation :D)
jszym
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]#1036 / Aug 15, 2011 6:46pm
Thanks Ben,
Just to be clear, it’s located in the Ion Auth model, right? (I’ve substituted it for a bcrypt implementation :D)
jszym
#1037 / Aug 16, 2011 7:46pm
jszym,
That is correct.
#1038 / Aug 18, 2011 6:04am
Using Ion 2
Small problem, first the function $this->ion_auth->is_group($group) should be in_group().
I think I remember seeing this elsewhere. However a problem exists if you pass an array of groups.
Currently is_group returns in_array($check_group, $groups) which won’t work if check_group is an array.
Solution:
application/libraries/Icon_auth.php
Add condition to check if $check_groups is an array and if it is then walk through the array checking for a match.
public function in_group($check_group)
{
$this->ci->ion_auth_model->trigger_events('is_group');
$users_groups = $this->ci->ion_auth_model->get_users_groups();
$groups = array();
foreach ($users_groups as $group)
{
$groups[] = $group->name;
}
$permission = false;
if(is_array($check_group)) {
foreach($check_group as $key => $value){
if(in_array($value, $groups)) {
$permission = true;
}
}
} else {
if(in_array($check_group, $groups)) {
$permission = true;
}
}
return $permission;
}Otherwise love your work
#1039 / Aug 19, 2011 10:09am
Kevin,
Thanks dude, that looks awesome. Can you send me a pull request on github? In travelling this weekend so if you do that I can merge it from my phone, thanks!
#1040 / Aug 19, 2011 4:36pm
I was just poking around in the code for Ion_auth 2. I love how the library has been refactored and streamlined. But I do have a question. What exactly does trigger_events() do?
#1041 / Aug 19, 2011 11:54pm
ammonkc,
trigger_events() will call all the hooks that were set with the set_hook() method.
#1042 / Aug 20, 2011 1:38pm
Does anyone have any suggestions on the best way to implement an online user list/chat (based on Ion Auth of course)?
The chat is straight forward, and not too much trouble.
The online list is what’s causing a bit of pain (As I want to display an on line list of admins, It’s just the ‘how’ do you distinguish an ‘online’ user and how is that status stored.)
If anyone’s implemented such things in their projects, I’d be interested in hearing how you went about it.
Thank you
#1043 / Aug 20, 2011 4:43pm
Hi Ben,
thanks a lot for your work! I’m currently doing some studies in overloading methods and I would like your comments on my observations of your work, to help me in my learning curve.
I’m writting to you, because I’ve been reading your library and in the first lines of code I’ve noticed that you declared a overloading method __call() to minimize the effort to call ion_auth_model methods. While we can understand and confirm it from __call() body code, the truth is that you don’t actually use it afterwards. My question is, why ? After checking more code I realised that this had to be with name collisions.
At line 117, we have method __call() defined,
/**
* __call
*
* Acts as a simple way to call model methods without loads of stupid alias'
*
**/
public function __call($method, $arguments)
{
if (!method_exists( $this->ci->ion_auth_model, $method) )
{
throw new Exception('Undefined method Ion_auth::' . $method . '() called');
}
return call_user_func_array( array($this->ci->ion_auth_model, $method), $arguments);
}You see, the code is very readable, but right then you have,
/**
* Activate user.
*
* @return void
* @author Mathew
**/
public function activate($id, $code=false)
{
if ($this->ci->ion_auth_model->activate($id, $code))
{
$this->set_message('activate_successful');
return TRUE;
}
$this->set_error('activate_unsuccessful');
return FALSE;
}I’ve been wondering why did you bothered to wrote __call ?
Thanks for looking 😉
#1044 / Aug 20, 2011 7:52pm
We use call for a lot of methods that aren’t defined in the library. If we need to do something extra in the library we just define it and call the model in that method.
#1045 / Aug 27, 2011 3:30pm
found a bug in V2, in /controllers/auth.php
line 119: $user = $this->ion_auth->get_user($this->session->userdata(‘user_id’));
change to: $user = $this->ion_auth->user($this->session->userdata(‘user_id’))->row();
#1046 / Aug 29, 2011 10:08am
Dear, Ben,.... I’m new on this, I’ve send you an e mail which ask how to get username in ion_auth 2.4.0
I wonder, why should you delete the feature of get user profile from ion_auth (although it is possible to get it from database and session)
Since I don’t know what the reason is, I add this code to ion_auth_model.php :
/**
* get_user
*
* @return array
* @author goFrendiAsgard
**/
public function get_profile($id=FALSE)
{
//if no id was passed use the current users id
$id || $id = $this->session->userdata('user_id');
return $this->db->select('username, email')
->where('id', $id)
->get($this->tables['users'])
->row_array();
}Do you think it is okay to add this method on the next release (sorry, it is just an suggestion), I need to show “Welcome user” on my page,....
Also, IMHO you should delete this, since I can’t see any purpose to keep it there,....
/**
* Profile
*
* @TODO want to get rid of this
* @return void
* @author Mathew
**/
public function profile()
{
$this->ci->ion_auth_model->trigger_events('profile');
$session = $this->ci->config->item('identity', 'ion_auth');
$identity = $this->ci->session->userdata($session);
return $this->ci->ion_auth_model->profile($identity);
}Thank you Ben, I like your ion_auth, it saves my times,.....
#1047 / Aug 29, 2011 12:10pm
Any idea when the docs will be updated?
#1048 / Aug 29, 2011 12:14pm
dallen33,
With my current work schedule it’ll be weeks before I get to it. You’re more than welcome to send me a pull request for it though, that would be awesome of you.
#1049 / Aug 29, 2011 12:15pm
I’ll give it a shot. Worried I’ll screw something up though.
#1050 / Aug 29, 2011 12:15pm
goFrendiAsgard,
I sent you an email, you just do $this->ion_auth->current()->user()->row();