Anthony
Anthony

Reputation: 5433

Interface not working in Laravel 4

I'm trying to implement Laravel Auth Token (https://github.com/tappleby/laravel-auth-token) and so far it's installed ok, but when I try to POST a username/password to it, it fails. I've traced the issue down to this:

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Auth\UserInterface, instance of User given

Basically the code runs:

$user = $this->users->retrieveByCredentials($credentials);

.. to retrieve a user (which works: It returns a User model). It then runs:

$this->users->validateCredentials($user, $credentials)

That's where the crash happens. I checked my User model and at the top is:

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

class User extends Eloquent {
 ...
}

I would think this makes my User model an instance of UserInterface, right?

Is there any way to check what instances my User can represent, and/or debug why the UserInterface isn't applying?

Upvotes: 1

Views: 308

Answers (1)

rmobis
rmobis

Reputation: 26992

No, what would make your User class an instance of Illuminate\Auth\UserInterface would be if it actually implemented the interface. You should have something like this:

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

class User extends Eloquent implements UserInterface {
    ...
}

Upvotes: 5

Related Questions