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.

38 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. if($storeUsersModel->password === $password){
  14. return $storeUsersModel;
  15. }else{
  16. throw new ErrorCodeException(ErrorCode::STORE_LOGIN_ERROR);
  17. }
  18. }
  19. public function check()
  20. {
  21. // TODO: Implement check() method.
  22. }
  23. public function undo()
  24. {
  25. // TODO: Implement undo() method.
  26. }
  27. function stringHash($password,$salt)
  28. {
  29. $authkey = config('lgoin.authkey');
  30. $password = "{$password}-{$salt}-{$authkey}";
  31. return sha1($password);
  32. }
  33. }