Files
exchange-2.0/app/Classes/Modules/Accounts/Standards/Criteria/PasswordResetTokenExists.php
T
omair saleh 05401f6bbc large commit
2021-03-11 13:06:40 +08:00

39 lines
827 B
PHP

<?php
namespace App\Classes\Modules\Accounts\Standards\Criteria;
use App\Classes\Exceptions\ResourceNotFoundException;
use App\Models\PasswordReset;
class PasswordResetTokenExists
{
/** @var PasswordReset */
private $repository;
/**
* TokenExistsValidation constructor.
* @param PasswordReset $repository
*/
public function __construct(PasswordReset $repository)
{
$this->repository = $repository;
}
/**
* @param string $token
* @return bool
* @throws ResourceNotFoundException
*/
public function execute(string $token){
if(!$this->repository->active()->where('token', $token)->first()){
throw new ResourceNotFoundException('The reset password token has expired or doesn\'t exist');
}
return true;
}
}