Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Listeners;
  4.  
  5. use Illuminate\Auth\Events\Failed;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use App\User as User;
  9. use MikeMcLin\WpPassword\Facades\WpPassword;
  10. use Auth;
  11. use Hash;
  12.  
  13. class LogFailedAuthenticationAttempt
  14. {
  15. /**
  16. * Create the event listener.
  17. *
  18. * @return void
  19. */
  20. public function __construct()
  21. {
  22. //
  23. }
  24.  
  25. /**
  26. * Handle the event.
  27. *
  28. * @param Login $event
  29. * @return void
  30. */
  31. public function handle(Failed $event)
  32. {
  33. $user = User::where('email',$event->credentials['email'])->first();
  34.  
  35. if ( $user ) {
  36. if ( WpPassword::check($event->credentials['password'], $user->password ) ) {
  37. Auth::login($user);
  38.  
  39. $user->password = Hash::make($event->credentials['password']);
  40. $user->save();
  41.  
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement