예제 #1
0
 public function executeRequest(RequestInterface $request) : ResponseInterface
 {
     try {
         $token = $this->authenticationService->login($request['email_address'], $request['password']);
         return new Response(self::MESSAGE, ['token' => $token->getUuid()->toString(), 'pass_code' => $token->getPassCode(), 'expires' => $token->getExpires()->format('Y-m-d H:i:s')], $request);
     } catch (AuthException $exception) {
         return new Response($exception->getMessage(), [], $request);
     } catch (\Throwable $exception) {
         $this->log(LogLevel::ERROR, $exception->getMessage());
         throw new ResponseException('An error occurred during LoginHandler.', new ServerErrorResponse([], $request));
     }
 }
예제 #2
0
 public function it_can_handle_errors_when_executing_a_request(RequestInterface $request)
 {
     $emailAddress = '*****@*****.**';
     $password = '******';
     $request->getAcceptContentType()->willReturn('*/*');
     $request->offsetGet('email_address')->willReturn($emailAddress);
     $request->offsetGet('password')->willReturn($password);
     $this->authenticationService->login($emailAddress, $password)->willThrow(new \RuntimeException());
     $this->shouldThrow(ResponseException::class)->duringExecuteRequest($request);
 }