Repository URL to install this package:
|
Version:
1.0.0 ▾
|
<?php namespace Modules\Users\Commands\Handlers;
use Modules\Core\Contracts\Authentication;
use Modules\Users\Events\UserHasBegunResetProcess;
use Modules\Users\Exceptions\UserNotFoundException;
use Modules\Users\Repositories\UserRepository;
class BeginResetProcessCommandHandler
{
/**
* @var UserRepository
*/
private $user;
/**
* @var Authentication
*/
private $auth;
public function __construct(UserRepository $user, Authentication $auth)
{
$this->user = $user;
$this->auth = $auth;
}
/**
* Handle the command
*
* @param $command
* @throws UserNotFoundException
* @return mixed
*/
public function handle($command)
{
$user = $this->findUser((array)$command);
$code = $this->auth->createReminderCode($user);
event(new UserHasBegunResetProcess($user, $code));
}
private function findUser($credentials)
{
$user = $this->user->findByCredentials((array)$credentials);
if ($user) {
return $user;
}
throw new UserNotFoundException();
}
}