7
        $userdata = array(
            'email' => Input::get('email'),
            'password'  => Input::get('password')
            );



        if (Auth::attempt($userdata)) {

            echo 'SUCCESS!';

        } else {        

            return Redirect::to('login');

        }

when i run the application from browser i got this error :

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Auth\UserInterface, instance of User given, called in /home/srtpl17/Sites/yatin.sr/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 316 and defined

What have I done incorrectly?

1
  • same problem here also.i m using laravel 4 . modifying to class User extends Eloquent implements UserInterface is causing more errors Commented Mar 26, 2014 at 5:32

3 Answers 3

7

It sounds like from your error that your User model does not implement UserInterface (the default User Model that comes with Laravel does this properly, so I'm guessing you made a custom one)

http://github.com/laravel/laravel/blob/master/app/models/User.php

Make sure that the User model looks like this:

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {


/**
 * Get the unique identifier for the user.
 *
 * @return mixed
 */
public function getAuthIdentifier()
{
    return $this->getKey();
}

/**
 * Get the password for the user.
 *
 * @return string
 */
public function getAuthPassword()
{
    return $this->password;
}

/**
 * Get the e-mail address where password reminders are sent.
 *
 * @return string
 */
public function getReminderEmail()
{
    return $this->email;
}

// Add your other methods here

}
Sign up to request clarification or add additional context in comments.

3 Comments

this is a good point... can we see the definition of the User model class? it should have something like: class User extends Eloquent implements UserInterface
@warspite This answer is correct, make sure you implement the UserInterface and RemindableInterface, github.com/laravel/laravel/blob/master/app/models/User.php
for later comacrossers, the default user.php is at github.com/laravel/laravel/blob/master/app/User.php now
1

You don't show what userdata is defined as, but from the error message it seems like it's an instance of your User model class.

The Auth::attempt() method is looking for an array of the credentials not a model.

Comments

0

This error might also appear when you use a different model for users (example :member) if it's the case you need to update Authentication Model and Authentication Table in app/config/auth.php with the appropriate model / database table.

1 Comment

I have done that and I still getting the same error. Any other option?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.