Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed shop api /verify-account route #386

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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