Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index: username in vendor/zizaco/confide/src/Zizaco/Confide/Confide.php line 108 #34

Closed
sambenskin opened this issue Mar 10, 2013 · 11 comments

Comments

@sambenskin
Copy link

I'm getting this error after logging in (I was testing attempting logging in before confirming the account using the link in the email)

ErrorException: Notice: Undefined index: username in vendor/zizaco/confide/src/Zizaco/Confide/Confide.php line 108

@Zizaco
Copy link
Owner

Zizaco commented Mar 11, 2013

I will take a look at this asap.

@TKlement
Copy link

Yes, same here.
After installing and configuring confide as it is said in the manual, I only inserted this line
`


{{ Confide::makeLoginForm()->render() }}

` into my template to get the formular working. Great, it works! But when I try to submit that form, no matter if I fill in an email or not, when I submit I get this error message like sbenskin. It seems that you have removed the field "username" in the credential array and so it can't get found.

@TKlement
Copy link

To fix this alter this line public function logAttempt( $credentials, $confirmed_only = false, $identity_columns = array('username', 'email') )
into this public function logAttempt( $credentials, $confirmed_only = false, $identity_columns = array('email') )

The array in the UserController assigns only email, password and remember but NOT username.
public function do_login() { $input = array( 'email' => Input::get( 'email' ), // May be the username too 'password' => Input::get( 'password' ), 'remember' => Input::get( 'remember' ), );
Maybe Zizaco can fix this and provide us a new update.

Oh, and please fix the notation "remamber" to "remember", too. You find this also in the UserController.

Many thanks for your great work.

@richlove1
Copy link

it's something to do with the last 3 commits and the code in Confide.php:

Guys I think there's issues with these identity based commits, I'm getting a 500 internal server. Looking at the logs shows:

'Notice: Undefined index: username in /Web/laravel/vendor/zizaco/confide/src/Zizaco/Confide/Confide.php line 108' in /Web/laravel/vendor/zizaco/confide/src/Zizaco/Confide/Confide.php:108

I think the culprit is the following. It's looking for username in the input ($credentials) fields from the login form because you have it in $identity_columns but the username field isn't defined from the input form

                $identity_columns = array_values($identity_columns);
                foreach ($identity_columns as $i => $column) {

                    echo $column;

                    if($i == 0)
                    {
                        $user_model = $user_model->where($column,'=',$credentials[$column]);
                    }
                    else
                    {
                        $user_model = $user_model->orWhere($column,'=',$credentials[$column]);
                    }

                }

@andrew13
Copy link
Collaborator

See #36 for one way to fix it.

@andrew13
Copy link
Collaborator

There's two way to fix it imo:

  1. remove username from the array in the logAttempt method
  2. assign the email form value to both email and username.

Since Confide by default has a username I would say use the second. If a developer only wants to allow email login then they can extend the Zizaco/Confide/Confide.php and change the default.

class ExtendConfide extends Confide
public function logAttempt( $credentials, $confirmed_only = false, $identity_columns = array('email') )
{
    return parent::logAttempt($credentials, $confirmed_only, $identity_columns)
}

Then it would default to email only.

@richlove1
Copy link

Yeah all good thanks, i went for the second option.

@andrew13
Copy link
Collaborator

Welcome!

@Zizaco
Copy link
Owner

Zizaco commented Mar 22, 2013

It seems that he bug is not solved #42

@Zizaco Zizaco reopened this Mar 22, 2013
@andrew13
Copy link
Collaborator

I think it is, his controller isn't modified correctly. #43 (comment)

@Zizaco
Copy link
Owner

Zizaco commented Mar 24, 2013

@andrew13, right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants