canAuthenticateUser = $canAuthenticateUser; $this->authenticatesUser = $authenticatesUser; $this->generatesAuthenticationToken = $generatesAuthenticationToken; $this->fetchesUser = $fetchesUser; $this->authenticationRedirect = $authenticationRedirect; $this->checkMilestonesForRewardProcessor = $checkMilestonesForRewardProcessor; $this->newCustomerToVoucherifyProcessor = $newCustomerToVoucherifyProcessor; } /** * @param Request $request * @return array * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\AccessUnauthorisedException * @throws \App\Classes\Exceptions\RequestValidationException */ public function execute(Request $request, bool $isSignIn = true): array { $object = new AuthenticationCredentialsObject($request->input('email'), $request->input('password')); $this->canAuthenticateUser->passes($object); $this->authenticatesUser->execute($object); $user = $this->fetchesUser->execute(['email' => $object->getEmail()]); if($isSignIn){ $this->newCustomerToVoucherifyProcessor->execute(0, $user, false); } //cief todo: case study 1 //$this->checkMilestonesForRewardProcessor->execute($user, [Milestones::MILESTONE_DEMO_1]); return ['access_token' => $this->generatesAuthenticationToken->execute($user), 'redirect_url' => $this->authenticationRedirect->url($user)]; } }