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()));
    }
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()));
    }
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 ( ) ) ) ; }
Checks the provided username and password against the AuthenticationService and
returns the active user

@param  type                           $data
@return type
@throws Exception\LoginFailedException
Checks the provided username and password against the AuthenticationService and returns the active user