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

[eluser]Ben Edmunds[/eluser]
dtechplus,

You are the guy that emailed me right?

[eluser]dtechplus[/eluser]
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.

[eluser]dtechplus[/eluser]
...So the email path is correct.

[eluser]Timothy_[/eluser]
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

[eluser]Phil Sturgeon[/eluser]
[quote author="Timothy_" date="1279534680"]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[/quote]

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.

[eluser]ChrisMiller[/eluser]
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...
Code:
stdClass Object (
    [id] => 1
    [group_id] => 1
    [ip_address] => 127.0.0.1
    [username] => administrator
    [password] => 59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4
    [salt] => 9462e8eee0
    [email] => [email protected]
    [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....
Code:
/**
* 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

[eluser]ChrisMiller[/eluser]
[quote author="Phil Sturgeon" date="1279547626"]
[quote author="Timothy_" date="1279534680"]
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[/quote]

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.[/quote]

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...
Code:
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 ****

[eluser]dtechplus[/eluser]
One of the most useful functions in Ion Auth (for me) is the
Code:
is_group()
. From the Ion Auth manual:
Code:
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
Code:
is_group
is set up, I'll have to do this:

Code:
$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
Code:
is_group()
to (also) accept an array parameter will make things easier:
editing above code...

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?

[eluser]Ben Edmunds[/eluser]
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.

[eluser]dtechplus[/eluser]
[quote author="Ben Edmunds" date="1279769929"]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.[/quote]

Indeed it does! Beautiful! :-)




Theme © iAndrew 2016 - Forum software by © MyBB