Laravel Individual Authentication

I am starting to open Laravel 5, so I may need a little of your help to understand a few things.

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

However, I want to display the login page (I know how to do it!), But after that I would like to send the credentials to the server via an API call. Then the server will tell me if the user is allowed to log in or not.

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

Can you confirm that you need to use your own authentication driver for this? I am 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 if you need it.

thanks

+6
source share
2 answers

I tried to follow the same topic you were talking about, and came to the same results. Then I checked the implementation of my own 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 is a more correct approach, as suggestions from the forum thread seem possible for the older / beta version of L5.

+6
source

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 { 

Now it works :-)

+2
source

Source: https://habr.com/ru/post/983405/


All Articles