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

[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 ****


Messages In This Thread
Ion Auth - Lightweight Auth System based on Redux Auth 2 - by El Forum - 07-19-2010, 09:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB