Skip to content

Commit

Permalink
bug #386 Fixed shop api /verify-account route ()
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------

In order to complete the activation of new registered users I propose to change the method of `sylius_shop_api_user_verification` route to [GET] so we are able to access the activation url sent in ShopApiPlugin:Email:verification.html.twig template, when a user registers through shop api.

Commits
-------

1726027 Fixed shop api /verify-account route
fd98158 Fixed tests on CustomerVerifyApiTest according to proposed changes
d41eddb Get parameter from query parameters instead of search it everywhere
  • Loading branch information
lchrusciel authored Feb 8, 2019
2 parents 50b745a + d41eddb commit bc9f836
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Request/VerifyAccountRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VerifyAccountRequest

public function __construct(Request $request)
{
$this->token = $request->request->get('token');
$this->token = $request->query->get('token');
}

public function getCommand(): VerifyAccount
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routing/register.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sylius_shop_api_resend_verification_token:

sylius_shop_api_user_verification:
path: /verify-account
methods: [PUT]
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.customer.verify_account_action

Expand Down
8 changes: 4 additions & 4 deletions tests/Controller/CustomerVerifyApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function it_allows_to_verify_customer()
$userRepository = $this->get('sylius.repository.shop_user');
$user = $userRepository->findOneByEmail('vinny@fandf.com');

$verifyEmail = sprintf('{"token": "%s"}', $user->getEmailVerificationToken());
$parameters = ['token' => $user->getEmailVerificationToken()];

$this->client->request('PUT', '/shop-api/WEB_GB/verify-account', [], [], ['CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json'], $verifyEmail);
$this->client->request('GET', '/shop-api/WEB_GB/verify-account', $parameters, [], ['ACCEPT' => 'application/json']);

$response = $this->client->getResponse();
$this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
Expand Down Expand Up @@ -67,9 +67,9 @@ public function it_does_not_allow_to_verify_customer_in_non_existent_channel()
$userRepository = $this->get('sylius.repository.shop_user');
$user = $userRepository->findOneByEmail('vinny@fandf.com');

$verifyEmail = sprintf('{"token": "%s"}', $user->getEmailVerificationToken());
$parameters = ['token' => $user->getEmailVerificationToken()];

$this->client->request('PUT', '/shop-api/SPACE_KLINGON/verify-account', [], [], ['CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json'], $verifyEmail);
$this->client->request('GET', '/shop-api/SPACE_KLINGON/verify-account', $parameters, [], ['CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json']);

$response = $this->client->getResponse();
$this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
Expand Down
2 changes: 1 addition & 1 deletion tests/Request/VerifyAccountRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class VerifyAccountRequestTest extends TestCase
*/
public function it_creates_put_simple_item_to_cart_command()
{
$verifyAccountRequest = new VerifyAccountRequest(new Request([], ['token' => 'RANDOMSTRINGAFAFAKASNFJAFAJ'], []));
$verifyAccountRequest = new VerifyAccountRequest(new Request(['token' => 'RANDOMSTRINGAFAFAKASNFJAFAJ'], [], []));

$this->assertEquals($verifyAccountRequest->getCommand(), new VerifyAccount('RANDOMSTRINGAFAFAKASNFJAFAJ'));
}
Expand Down

0 comments on commit bc9f836

Please sign in to comment.