You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

5 years ago
5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Constants\v3\ErrorCode;
  4. use App\Exception\ErrorCodeException;
  5. use App\Model\v3\StoreUsers;
  6. use App\Service\v3\Interfaces\StoreLoginServiceInterface;
  7. class StoreLoginService implements StoreLoginServiceInterface
  8. {
  9. public function do($account,$password)
  10. {
  11. $storeUsersModel = StoreUsers::query()->where('username',$account)->first();
  12. $password = $this->stringHash($password,$storeUsersModel->salt);
  13. var_dump($storeUsersModel,$password);
  14. if($storeUsersModel->password === $password){
  15. return $storeUsersModel;
  16. }else{
  17. throw new ErrorCodeException(ErrorCode::STORE_LOGIN_ERROR);
  18. }
  19. }
  20. public function check()
  21. {
  22. // TODO: Implement check() method.
  23. }
  24. public function undo()
  25. {
  26. // TODO: Implement undo() method.
  27. }
  28. function stringHash($password,$salt)
  29. {
  30. $authkey = config('lgoin.authkey');
  31. $password = "{$password}-{$salt}-{$authkey}";
  32. return sha1($password);
  33. }
  34. }