7

I'm starting to discover Laravel 5, so I might need a bit of your help to understand a few things.

First, I want to develop a login page. It seems that Laravel has a whole authentication system, and I guess I should use it.

Nevertheless, I want to display a login page (I know how to do this!), but after this, I would like to send the credentials to a server via an API call. The server will then tell me if the user is allowed to log in or not.

As far I understand Laravel and authentication, it seems that the authentication system works only with a local DB.

Can you confirm I need to use a custom authentication driver to do this? I've been following this solution but I get this error when loading my page:

FatalErrorException in CustomUserProvider.php line 6:
Interface 'Illuminate\Auth\UserProviderInterface' not found

Any help would be appreciated, feel free to ask me for more information if you need it.

Thanks

1
  • You do need to use a custom authentication driver. I think in the the current version of Laravel 5 the interface is Illuminate\Contracts\Auth\UserProvider. Commented Mar 6, 2015 at 1:47

2 Answers 2

7

I tried following the same thread you mentioned and arrived at the very same results. Then I checked the implementation of native UserProviders (Illuminate/Auth/EloquentUserProvider and Illuminate/Auth/DatabaseUserProvider) and ended up using the same set as in EloquentUserProvider:

<?php namespace App\Auth;

use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;

class MyUserProvider implements UserProvider {
   // Implementation goes here
}

I believe this to be more correct approach as the suggestions from the forum thread seem to be possibly for an older/beta version of L5.

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

Comments

1

Here is my CustomUserProvider file:

<?php namespace App\Auth;

use Illuminate\Contracts\Auth\UserProvider as UserProviderInterface;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\GenericUser;

class CustomUserProvider implements UserProviderInterface {

It's now working :-)

Comments

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.