users = $users; $this->bus = $bus; $this->events = $events; } /** * {@inheritdoc} */ public function handle(ServerRequestInterface $request): ResponseInterface { $body = $request->getParsedBody(); $identification = Arr::get($body, 'identification'); $password = Arr::get($body, 'password'); $lifetime = Arr::get($body, 'lifetime', 3600); $user = $this->users->findByIdentification($identification); if (! $user || ! $user->checkPassword($password)) { throw new NotAuthenticatedException; } // Use of lifetime attribute is deprecated in beta 16, removed in beta 17 // For backward compatibility with custom integrations, longer lifetimes will be interpreted as remember tokens if ($lifetime > 3600 || Arr::get($body, 'remember')) { if ($lifetime > 3600) { trigger_error('Use of parameter lifetime is deprecated in beta 16, will be removed in beta 17. Use remember parameter to start a remember session', E_USER_DEPRECATED); } $token = RememberAccessToken::generate($user->id); } else { $token = SessionAccessToken::generate($user->id); } // We do a first update here to log the IP/agent of the token creator, even if the token is never used afterwards $token->touch($request); return new JsonResponse([ 'token' => $token->token, 'userId' => $user->id ]); } }