Last active
July 24, 2017 06:25
-
-
Save jeffreyvr/66928351b6b2113451b2dec7970389e3 to your computer and use it in GitHub Desktop.
Add WordPress password validation to Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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