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
Just run php artisan make:auth and php artisan migrate in a fresh Laravel application. Then, navigate your browser to http://your-app.test/register or any other URL that is assigned to your application. These two commands will take care of scaffolding your entire authentication system!
Laravel includes built-in authentication and session services which are typically accessed via the Auth and Session facades. These features provide cookie-based authentication for requests that are initiated from web browsers. They provide methods that allow you to verify a user's credentials and authenticate the user.
The attempt method accepts an array of key / value pairs as its first argument. The values in the array will be used to find the user in your database table. So, in the example above, the user will be retrieved by the value of the email column.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With