Skip to content

Instantly share code, notes, and snippets.

@jeffreyvr
Last active July 24, 2017 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyvr/66928351b6b2113451b2dec7970389e3 to your computer and use it in GitHub Desktop.
Save jeffreyvr/66928351b6b2113451b2dec7970389e3 to your computer and use it in GitHub Desktop.
Add WordPress password validation to Laravel
<?php
namespace App\Listeners;
use Illuminate\Auth\Events\Failed;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\User as User;
use MikeMcLin\WpPassword\Facades\WpPassword;
use Auth;
use Hash;
class LogFailedAuthenticationAttempt
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param Failed $event
* @return void
*/
public function handle(Failed $event)
{
$user = User::where('email',$event->credentials['email'])->first();
if ( $user ) {
if ( WpPassword::check($event->credentials['password'], $user->password ) ) {
Auth::login($user);
$user->password = Hash::make($event->credentials['password']);
$user->save();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment