CheckPasswordValidator.php 708 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace UCore\Validator;
  3. use App\Module\User\Services\UserService;
  4. use UCore\Validator;
  5. class CheckPasswordValidator extends Validator
  6. {
  7. /**
  8. * @param mixed $value
  9. * @param array $data
  10. * @return bool
  11. * 验证交易密码
  12. */
  13. public function validate(mixed $value, array $data): bool
  14. {
  15. // 判断是否绑定谷歌
  16. $isGoogle = UserService::isBindGoogle($data['userId']);
  17. if ($isGoogle) {
  18. return true;
  19. } else {
  20. $check = UserService::checkSecretPassword($data['userId'], $data['password']);
  21. if (!$check) {
  22. return false;
  23. }
  24. return true;
  25. }
  26. }
  27. }