public function configureAction(Request $request)
    {
        if ($this->get('tenside.status')->isTensideConfigured()) {
            throw new NotAcceptableHttpException('Already configured.');
        }
        $inputData = new JsonArray($request->getContent());

        $secret = bin2hex(random_bytes(40));
        if ($inputData->has('credentials/secret')) {
            $secret = $inputData->get('credentials/secret');
        }

        // Add tenside configuration.
        $tensideConfig = $this->get('tenside.config');
        $tensideConfig->set('secret', $secret);

        if ($inputData->has('configuration')) {
            $this->handleConfiguration($inputData->get('configuration', true));
        }
        $user = $this->createUser($inputData->get('credentials/username'), $inputData->get('credentials/password'));

        return new JsonResponse(
            [
                'status' => 'OK',
                'token'  => $this->get('tenside.jwt_authenticator')->getTokenForData($user)
            ],
            JsonResponse::HTTP_CREATED
        );
    }
public function configureAction(Request $request)
    {
        if ($this->get('tenside.status')->isTensideConfigured()) {
            throw new NotAcceptableHttpException('Already configured.');
        }
        $inputData = new JsonArray($request->getContent());

        $secret = bin2hex(random_bytes(40));
        if ($inputData->has('credentials/secret')) {
            $secret = $inputData->get('credentials/secret');
        }

        // Add tenside configuration.
        $tensideConfig = $this->get('tenside.config');
        $tensideConfig->set('secret', $secret);

        if ($inputData->has('configuration')) {
            $this->handleConfiguration($inputData->get('configuration', true));
        }
        $user = $this->createUser($inputData->get('credentials/username'), $inputData->get('credentials/password'));

        return new JsonResponse(
            [
                'status' => 'OK',
                'token'  => $this->get('tenside.jwt_authenticator')->getTokenForData($user)
            ],
            JsonResponse::HTTP_CREATED
        );
    }
public function configureAction ( Request $ request ) { if ( $ this -> get ( 'tenside.status' ) -> isTensideConfigured ( ) ) { throw new NotAcceptableHttpException ( 'Already configured.' ) ; } $ inputData = new JsonArray ( $ request -> getContent ( ) ) ; $ secret = bin2hex ( random_bytes ( 40 ) ) ; if ( $ inputData -> has ( 'credentials/secret' ) ) { $ secret = $ inputData -> get ( 'credentials/secret' ) ; } // Add tenside configuration. $ tensideConfig = $ this -> get ( 'tenside.config' ) ; $ tensideConfig -> set ( 'secret' , $ secret ) ; if ( $ inputData -> has ( 'configuration' ) ) { $ this -> handleConfiguration ( $ inputData -> get ( 'configuration' , true ) ) ; } $ user = $ this -> createUser ( $ inputData -> get ( 'credentials/username' ) , $ inputData -> get ( 'credentials/password' ) ) ; return new JsonResponse ( [ 'status' => 'OK' , 'token' => $ this -> get ( 'tenside.jwt_authenticator' ) -> getTokenForData ( $ user ) ] , JsonResponse :: HTTP_CREATED ) ; }
Configure tenside.

NOTE: This method will become inaccessible after the first successful call.

@param Request $request The request.

@return JsonResponse

@throws NotAcceptableHttpException When the configuration is already complete.

@ApiDoc(
section="install",
statusCodes = {
201 = "When everything worked out ok",
406 = "When the configuration is already complete"
}
)
@ApiDescription(
request={
"credentials" = {
"description" = "The credentials of the admin user.",
"children" = {
"secret" = {
"dataType" = "string",
"description" = "The secret to use for encryption and signing.",
"required" = true
},
"username" = {
"dataType" = "string",
"description" = "The name of the admin user.",
"required" = true
},
"password" = {
"dataType" = "string",
"description" = "The password to use for the admin.",
"required" = false
}
}
},
"configuration" = {
"description" = "The application configuration.",
"children" = {
"php_cli" = {
"dataType" = "string",
"description" = "The PHP interpreter to run on command line."
},
"php_cli_arguments" = {
"dataType" = "string",
"description" = "Command line arguments to add."
},
"github_oauth_token" = {
"dataType" = "string",
"description" = "Github OAuth token.",
"required" = false
}
}
}
},
response={
"token" = {
"dataType" = "string",
"description" = "The API token for the created user"
}
}
)
Configure tenside .