EllisLab text mark
Advanced Search
70 of 89
70
   
Ion Auth - Lightweight Auth System based on Redux Auth 2
Posted: 20 August 2011 01:38 PM   [ # 1041 ]   [ Rating: 0 ]
Avatar
Joined: 2010-05-21
23 posts

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

 Signature 

Thanks,
Andy!

 
Posted: 20 August 2011 04:43 PM   [ # 1042 ]   [ Rating: 0 ]
Joined: 2011-05-15
15 posts

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 wink

 
Posted: 20 August 2011 07:52 PM   [ # 1043 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
823 posts

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.

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 27 August 2011 03:30 PM   [ # 1044 ]   [ Rating: 0 ]
Joined: 2010-02-23
34 posts

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();

 
Posted: 29 August 2011 10:08 AM   [ # 1045 ]   [ Rating: 0 ]
Avatar
Joined: 2011-08-28
139 posts

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,.....

 Signature 

Homepage : http://www.getnocms.com
Github page : https://github.com/goFrendiAsgard/No-CMS

A free CodeIgniter based CMS-Framework, It is not just another CMS !!!

 
Posted: 29 August 2011 12:10 PM   [ # 1046 ]   [ Rating: 0 ]
Joined: 2008-10-01
146 posts

Any idea when the docs will be updated?

 
Posted: 29 August 2011 12:14 PM   [ # 1047 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
823 posts

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.

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 29 August 2011 12:15 PM   [ # 1048 ]   [ Rating: 0 ]
Joined: 2008-10-01
146 posts

I’ll give it a shot. Worried I’ll screw something up though.

 
Posted: 29 August 2011 12:15 PM   [ # 1049 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
823 posts

goFrendiAsgard,

I sent you an email, you just do $this->ion_auth->current()->user()->row();

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 29 August 2011 12:17 PM   [ # 1050 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
823 posts

dallen33,

Awesome! Thanks dude!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 29 August 2011 12:24 PM   [ # 1051 ]   [ Rating: 0 ]
Avatar
Joined: 2011-08-28
139 posts

@Ben Edmunds : Thank you,.... sorry to ask the same question through e mail, spark and this forum,.....

 Signature 

Homepage : http://www.getnocms.com
Github page : https://github.com/goFrendiAsgard/No-CMS

A free CodeIgniter based CMS-Framework, It is not just another CMS !!!

 
Posted: 29 August 2011 02:05 PM   [ # 1052 ]   [ Rating: 0 ]
Joined: 2010-02-23
34 posts

I am trying to run
$user = $this->ci->ion_auth_model->user($id)->row();

and it throws the errors

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Admin::$_where

Filename: core/Model.php

Line Number: 50

A PHP Error was encountered

Severity: Notice

Message: Indirect modification of overloaded property Ion_auth_model::$_where has no effect

Filename: models/ion_auth_model.php

Line Number: 753

it then returns the user info for the currently logged in user.

in your user function in ion_auth_model.php
if i remove the lines:

if (isset($id))
$this->where($this->tables['users'].'.id'$id); 

then the error goes away, but obviously im not getting the correct user

 
Posted: 29 August 2011 02:07 PM   [ # 1053 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
823 posts

ripken204,

You should be calling it through the library, not the model.  What happens if you do:

$user $this->ci->ion_auth->user($id)->row(); 
 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 29 August 2011 02:09 PM   [ # 1054 ]   [ Rating: 0 ]
Joined: 2010-02-23
34 posts

still throws the same errors

in function users in the model

//run each where that was passed
        
if (isset($this->_where))
        
{
            
foreach ($this->_where as $where)
                
$this->db->where($where);

            unset(
$this->_where);
        


if i comment out unset then the errors go away and i get the correct result

 
Posted: 29 August 2011 02:11 PM   [ # 1055 ]   [ Rating: 0 ]
Joined: 2010-02-23
34 posts

maybe doing

$this->_where = array(); 

instead of

unset($this->_where); 

is what you meant? you are trying to unset an array instead of reinitalizing an array.
unset is just for array keys

after that change, it’s working fine for me

 
70 of 89
70