Advertisement
Guest User

WordPressPasswordUpdate.php

a guest
Nov 21st, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. class WordPressPasswordUpdate
  2. {
  3. public function handle(Attempting $event)
  4. {
  5.  
  6. $this->check($event->credentials['password'], \App\User::where('email', $event->credentials['email'])->first()->password ?? 'not found');
  7. }
  8.  
  9. public function check($value, $hashedValue, array $options = [])
  10. {
  11. if ($this->needsRehash($hashedValue)) {
  12.  
  13. if ($this->user_check_password($value, $hashedValue)) {
  14.  
  15. $newHashedValue = (new \Illuminate\Hashing\BcryptHasher)->make($value, $options);
  16. \Illuminate\Support\Facades\DB::update('UPDATE users SET `password` = "' . $newHashedValue . '" WHERE `password` = "' . $hashedValue . '"');
  17. $hashedValue = $newHashedValue;
  18. }
  19. }
  20. }
  21.  
  22. public function needsRehash($hashedValue, array $options = [])
  23. {
  24. return substr($hashedValue, 0, 4) != '$2y;
  25. }
  26.  
  27. // WP PASSWORD FUNCTIONS
  28. function user_check_password($password, $stored_hash)
  29. {
  30. // $hash = md5($password);
  31.  
  32. if (WpPassword::check($password, $stored_hash)) {
  33. // Password success!
  34. return true;
  35. } else {
  36. // Password failed :(
  37. return false;
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement