Add ability to name the client

This commit is contained in:
Jeremy Benoist 2017-06-08 14:25:44 +02:00
parent eb570e49c8
commit a8d3fe50df
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
2 changed files with 6 additions and 4 deletions

View file

@ -28,13 +28,14 @@ class UserRestController extends WallabagRestController
}
/**
* Register an user.
* Register an user and create a client.
*
* @ApiDoc(
* requirements={
* {"name"="username", "dataType"="string", "required"=true, "description"="The user's username"},
* {"name"="password", "dataType"="string", "required"=true, "description"="The user's password"},
* {"name"="email", "dataType"="string", "required"=true, "description"="The user's email"}
* {"name"="email", "dataType"="string", "required"=true, "description"="The user's email"},
* {"name"="client_name", "dataType"="string", "required"=true, "description"="The client name (to be used by your app)"}
* }
* )
*
@ -100,7 +101,7 @@ class UserRestController extends WallabagRestController
// create a default client
$client = new Client($user);
$client->setName('Default client');
$client->setName($request->request->get('client_name', 'Default client'));
$this->getDoctrine()->getManager()->persist($client);

View file

@ -85,6 +85,7 @@ class UserRestControllerTest extends WallabagApiTestCase
'username' => 'google',
'password' => 'googlegoogle',
'email' => 'wallabag@google.com',
'client_name' => 'My client name !!',
]);
$this->assertEquals(201, $client->getResponse()->getStatusCode());
@ -104,7 +105,7 @@ class UserRestControllerTest extends WallabagApiTestCase
$this->assertArrayHasKey('client_secret', $content['default_client']);
$this->assertArrayHasKey('client_id', $content['default_client']);
$this->assertEquals('Default client', $content['default_client']['name']);
$this->assertEquals('My client name !!', $content['default_client']['name']);
$this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));