canAuthenticateUser = $canAuthenticateUser; $this->authenticatesUser = $authenticatesUser; $this->authenticationRedirect = $authenticationRedirect; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ protected function logic(Request $request): JsonResponse { try { $object = new AuthenticationCredentialsObject($request->input('email'), $request->input('password'), $request->input('remember_me')); $this->canAuthenticateUser->passes($object); $token = $this->authenticatesUser->execute($object); return $this->response(['access_token' => $token, 'redirect_url' => $this->authenticationRedirect->url()]); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }