original_string: public function create($data)
      {
          $authService = $this->options->getAuthenticationService();
  
          if ($authService->hasIdentity()) {
              $authService->logout();
          }
  
          $result = $authService->login(
              $data[$this->options->getDataUsernameKey()],
              $data[$this->options->getDataPasswordKey()],
              isset($data[$this->options->getDataRememberMeKey()]) ? $data[$this->options->getDataRememberMeKey()]: false
          );
          if (!$result->isValid()) {
              throw new Exception\LoginFailedException(implode('. ', $result->getMessages()));
          }
  
          $this->response->getHeaders()->addHeader(
              Location::fromString(
                  'Location: ' . $this->request->getUri()->getPath()
              )
          );
  
          return $this->model->setVariables($this->options->getSerializer()->toArray($result->getIdentity()));
      }
code: public function create($data)
      {
          $authService = $this->options->getAuthenticationService();
  
          if ($authService->hasIdentity()) {
              $authService->logout();
          }
  
          $result = $authService->login(
              $data[$this->options->getDataUsernameKey()],
              $data[$this->options->getDataPasswordKey()],
              isset($data[$this->options->getDataRememberMeKey()]) ? $data[$this->options->getDataRememberMeKey()]: false
          );
          if (!$result->isValid()) {
              throw new Exception\LoginFailedException(implode('. ', $result->getMessages()));
          }
  
          $this->response->getHeaders()->addHeader(
              Location::fromString(
                  'Location: ' . $this->request->getUri()->getPath()
              )
          );
  
          return $this->model->setVariables($this->options->getSerializer()->toArray($result->getIdentity()));
      }
code_tokens: public function create ( $ data ) { $ authService = $ this -> options -> getAuthenticationService ( ) ; if ( $ authService -> hasIdentity ( ) ) { $ authService -> logout ( ) ; } $ result = $ authService -> login ( $ data [ $ this -> options -> getDataUsernameKey ( ) ] , $ data [ $ this -> options -> getDataPasswordKey ( ) ] , isset ( $ data [ $ this -> options -> getDataRememberMeKey ( ) ] ) ? $ data [ $ this -> options -> getDataRememberMeKey ( ) ] : false ) ; if ( ! $ result -> isValid ( ) ) { throw new Exception \ LoginFailedException ( implode ( '. ' , $ result -> getMessages ( ) ) ) ; } $ this -> response -> getHeaders ( ) -> addHeader ( Location :: fromString ( 'Location: ' . $ this -> request -> getUri ( ) -> getPath ( ) ) ) ; return $ this -> model -> setVariables ( $ this -> options -> getSerializer ( ) -> toArray ( $ result -> getIdentity ( ) ) ) ; }
docstring: Checks the provided username and password against the AuthenticationService and
  returns the active user
  
  @param  type                           $data
  @return type
  @throws Exception\LoginFailedException
docstring_tokens: Checks the provided username and password against the AuthenticationService and returns the active user