ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ion Auth - Lightweight Auth System based on Redux Auth 2

February 10, 2010 7:00pm

Subscribe [287]
  • #466 / Jul 15, 2010 10:18pm

    Ben Edmunds

    812 posts

    prit,

    I don’t think I’ve even documented the default login in the userguide yet… where did you see the wrong login?

    Thanks,

  • #467 / Jul 15, 2010 10:18pm

    Ben Edmunds

    812 posts

    dtechplus,

    Made any progress yet?

  • #468 / Jul 15, 2010 10:46pm

    Ben Edmunds

    812 posts

    prit,

    The default login is documented now.

    http://benedmunds.com/ion_auth/#install


    Thanks and enjoy!

  • #469 / Jul 15, 2010 11:11pm

    jsherk

    12 posts

    CORRECTION to Docs:
    Reading thru the docs, I noticed that you have email_check() listed twice.
    I think the second email_check() should be identity_check().

    SUGGESTION:
    Also, another suggestion might be to clarify the difference between messages() and errors() by providing a little more detail as to what they can be expected to return and when to check them.

    FEATURE:
    And as a last suggestion/feature, perhaps a couple more functions:
    extra_orderby() to allow ordering of the results (would add an ‘ORDER BY fieldname ASC’ or ‘ORDER BY fieldname DESC’).
    extra_limit() to allow limiting the range/number of results returned (would add an ‘LIMIT x,y’).

    Thanks

  • #470 / Jul 16, 2010 9:18pm

    dtechplus

    8 posts

    dtechplus,

    Made any progress yet?

    Nope. Same problem persist. Emails still not displaying.

  • #471 / Jul 17, 2010 6:41pm

    Ben Edmunds

    812 posts

    dtechplus,

    You are the guy that emailed me right?

  • #472 / Jul 18, 2010 4:05am

    dtechplus

    8 posts

    Ben.
    Nope I didn’t email you. May be I might 😉 if I can’t get round this problem.

    That aside, I noticed that when I changed the line $config[‘mailtype’] = “html”;
    (line 334 or so) of the Ion_auth.php library file to $config[‘mailtype’] = “text”;
    I get text-only emails so I guess the problem has to do with HTML formatting.

  • #473 / Jul 18, 2010 4:06am

    dtechplus

    8 posts

    ...So the email path is correct.

  • #474 / Jul 19, 2010 2:18am

    Timothy_

    100 posts

    Hello,

    I have scanned through most of this thread, but I apologise in advance if this has already been discussed.

    I would like people to be able to log in with either their email address OR their user-name.

    I looked at the code to see if there was any scope for this and wasn’t able to find anything that indicates that Ion Auth lets you authenticate on both fields.

    Is there an option for this that I have missed or is there room for this in the future.

    Thanks

    Tim

  • #475 / Jul 19, 2010 5:53am

    Phil Sturgeon

    2889 posts

    Hello,

    I have scanned through most of this thread, but I apologise in advance if this has already been discussed.

    I would like people to be able to log in with either their email address OR their user-name.

    I looked at the code to see if there was any scope for this and wasn’t able to find anything that indicates that Ion Auth lets you authenticate on both fields.

    Is there an option for this that I have missed or is there room for this in the future.

    Thanks

    Tim

    Sorry dude it’s set up to work with one OR the other. It shouldn’t be too tough to modify the model to get this working. If you can think of an implementation that doesn’t break current functionality then me or Ben will be happy to put it into Ion Auth. GitHub fork FTW.

  • #476 / Jul 19, 2010 12:01pm

    ChrisMiller

    46 posts

    Hey,

    Firstly good job with the Library & Documentation, very good documentation and I can almost always find what I am looking for without searching to much but have one suggestion for it. One Suggestion is to add more to the section for function “get_user()” that actually shows what the return object is so its easier then having to dump it out and then pick through it to find what is what. Luckily I have nothing better to do so here ya go…

    stdClass Object ( 
        [id] => 1 
        [group_id] => 1 
        [ip_address] => 127.0.0.1 
        [username] => administrator 
        [password] => 59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4 
        [salt] => 9462e8eee0 
        [email] => .(JavaScript must be enabled to view this email address) 
        [activation_code] => 19e181f2ccc2a7ea58a2c0aa2b69f4355e636ef4 
        [forgotten_password_code] => 81dce1d0bc2c10fbdec7a87f1ff299ed7e4c9e4a 
        [remember_code] => 9d029802e28cd9c768e8e62277c0df49ec65c48c 
        [created_on] => 1268889823 
        [last_login] => 1279464628 
        [active] => 0 
        [group] => admin
        [group_description] => Administrator
        [first_name] => Admin 
        [last_name] => Account 
        [company] => Some Corporation
        [phone] => (123)456-7890
    )

    Also could you maybe add a function for accessing the current logged in users information instead of having to call the get_user() function… Example being….

    /**
     * Get User Item
     *
     * @return string
     * @author Chris Miller <[email protected]>
     **/
    public function get_user_item( $item=false, $id=0 ) {
    
        // Do we have a Valid Request????
        if ($item===false) return;
            
            
        // Does our User Obj Exist?? If no set it.
        if (!isset($this->user_obj[$id])){
            $this->user_obj[$id] = $this->get_user((($id==0) ? false : $id));
        }
            
        // Be nice and return requested Item or false if non-existant
        return (isset($this->user_obj[$id]->$item)) ? $this->user_obj[$id]->$item : false;
    }
    
    EXAMPLE USAGE:
    $this->ion_auth->get_user_item('email'); // Returns Current Logged in User Email
    $this->ion_auth->get_user_item('id');    // Returns Current Logged in Users ID
    $this->ion_auth->get_user_item('email',2); // Returns User ID #2's email address
    $this->ion_auth->get_user_item('fake_item'); // Returns (bool) false… non-existant

    Just a Suggestion, alot of other libraries have it and is useful at times like when I only need the ID so I can put it in the database when the post something. The function also stores the request to prevent excessive calls back to the get_user() function.

    Finially, You have the function “email_check()” twice in the documentation the second time it should say “identity_check()” you have the example correct just wrong title.

    Thanks Again,
    Chris

  • #477 / Jul 19, 2010 12:53pm

    ChrisMiller

    46 posts

    I would like people to be able to log in with either their email address OR their user-name.

    I looked at the code to see if there was any scope for this and wasn’t able to find anything that indicates that Ion Auth lets you authenticate on both fields.

    Is there an option for this that I have missed or is there room for this in the future.

    Thanks

    Tim

    Sorry dude it’s set up to work with one OR the other. It shouldn’t be too tough to modify the model to get this working. If you can think of an implementation that doesn’t break current functionality then me or Ben will be happy to put it into Ion Auth. GitHub fork FTW.

    Just a thought here but what about in the model we check to see if the identity is a valid email or just a string and then choose the appropriate table row…

    public function login($identity, $password, $remember=FALSE)
    {
        if (empty($identity) || empty($password) )
        {
            return FALSE;
        }
    
        // Multiple Logins Enabled??
        if($this->config->item('multiple_logins','ion_auth')===true){
            
            // We can login via username or email, OH Yeah sweet goodness!
            if(pregmatch('/[.+a-zA-Z0-9-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/',$identity)){
    
                // Email Login Attempt
                $this->db
                    ->select('email, id, password, group_id')
                    ->where('email', $identity);
            }else{
    
                // Username Login Attempt
                $this->db
                    ->select('username, id, password, group_id')
                    ->where('username', $identity);
            }
                
        }else{
    
            // Only One Login Type Enabled
            $this->db
                ->select($this->identity_column.', id, password, group_id')
                ->where($this->identity_column, $identity);
        }
    
       [ Rest of Function… ]
    }

    Obviously the Example adds a new Config Item so you can configure if they want to enable people to use emails and usernames to login depending on what they perfer.

    **** NOT TESTED YET ****

  • #478 / Jul 21, 2010 7:22pm

    dtechplus

    8 posts

    One of the most useful functions in Ion Auth (for me) is the

    is_group()

    . From the Ion Auth manual:

    is_group()
    Check to see if the currently logged in user is in the passed in group.
    Parameters : 'Group Name' - string REQUIRED.
    Return: boolean. TRUE if the user is in the group FALSE if the user is not in the group.

    Why this function accepts only strings beats me. Just a suggestion, but why not set it to also accept
    an array (of groups)? Better still either a string or an array.

    I mean, if I wanted to make a section of my app accessible to more than one group or (roles), the way

    is_group

    is set up, I’ll have to do this:

    $group1 = 'webmaster';
    $group2 = 'editor';
    $group3 = 'justme';
    
    if($this->ion_auth->is_group($group1) || $this->ion_auth->is_group($group2) || $this->ion_auth->is_group($group3)):
    $this->load->view('something',$data);         
    else:
    redirect('welcome/index');
    endif;

         

    Right??

    However setting

    is_group()

    to (also) accept an array parameter will make things easier:
    editing above code…

    $groups = array($group1,$group2,$group3);
    
    if($this->ion_auth->is_group($groups)):
    $this->load->view('something',$data);         
    else:
    redirect('welcome/index');
    endif;

     

    What do you guys think or did I miss something?

  • #479 / Jul 21, 2010 7:38pm

    Ben Edmunds

    812 posts

    Hey dtechplus,

    It does already accept an array.  It’s just not correct in the docs.  Thanks for pointing it out, I’ll update the docs soon.

  • #480 / Jul 21, 2010 8:54pm

    dtechplus

    8 posts

    Hey dtechplus,

    It does already accept an array.  It’s just not correct in the docs.  Thanks for pointing it out, I’ll update the docs soon.

    Indeed it does! Beautiful! 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases