I am using Laravel 3.2 to create a new website. My site is going to link in with an existing user database, meaning users from another site will be able to login to this site with their same account.
The existing site uses phpass so I figure, I'll need to use phpass in the Laravel site to make authentication work properly. I downloaded the phpass bundle for Laravel and I have it implemented just to hash passwords and check a password. Is there a way I can implement it into Laravels authentication classes, so using the normal Laravel authentication methods will use phpass?
You need to implement your own custom authentication driver. This is a relatively painless process and requires a little bit of custom code to get in working, but thankfully L3 is easy to extend.
Essentially you can extend one of the existing drivers (Eloquent or Fluent) and simply overload the attempt
method. Take a look at the Eloquent driver. The Hash::check()
method is located down on line 53. So basically, create a new file in libraries
for your driver, probably called phpass.php
and extend and adjust the driver.
You then use the Auth::extend()
method to register your driver.
Auth::extend('phpass', function()
{
return new Phpass;
}
Then set your driver in application/config/auth.php
.
'driver' => 'phpass'
Best of luck.