Support the ongoing development of Laravel.io →
Authentication Eloquent Installation
Last updated 1 year ago.
0

Laravel has some built in classes for validation: https://laravel.com/docs/5.2/validation and the validation functionality is pretty complete. then there are "FormRequests" https://laravel.com/docs/5.2/validation#form-request-validation, which actually get executed before any code in your controller actions.

but you can use validators most anywhere you want to instantiate them. validating on your controller could be a good way to catch errors before anything else happens, and controllers implement a trait called "validates requests" which make it easy to define velidation rules right there on the controller.

0

Hi Igalaz, and first of all thank you for your answer.

I think that the function name of the code I've posted can lead to misunderstandings.

Even if its name is "validateCredentials", it isn't called upon form validation phase, but after it, in order to log a user in.

After the login form validation (and only if result is ok), the "user login" function is called.

My problem is that with my legacy "Users" table, it is impossible to log in any user to the application due to the password check method.

So I'll try to rephrase the question: is there any standard way to modify the default password check of the Eloquent User Provider?

0

why not use Hash::check() https://laravel.com/docs/5.2/hashing#basic-usage

if (Hash::check('plain-text', $hashedPassword)) {
    // The passwords match...
}
Last updated 7 years ago.
0

Also you might wanna see this thread, read barryvdh's reply http://laravel.io/forum/03-18-2014-password-salt-just-wonderin...

Last updated 7 years ago.
0

Thank you astronau. Your last link drove me to the solution.

I had to implement a custom authentication provider. At the end I managed to do it, following the documentation that I've found to add custom authentication providers.

I think that can be useful to improve this documentation, because I was trying to implement this extension using the method described here, which hasn't been updated for version 5.2:

Auth::extend('riak', function($app)
{
    // Return implementation of Illuminate\Contracts\Auth\UserProvider
});

I had to use the "provider" function instead:

$this->app['auth']->provider('dbe', function($app, array $config) {
    // Return an instance of Illuminate\Contracts\Auth\UserProvider...
    return new DbeUserProvider($this->app['hash'], $config['model']);
});

Anyway now the extension is working, so thank you all for your help!

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

mafabio mafabio Joined 12 Aug 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.