Skip to content

Commit

Permalink
Returning 401 on customer details/update actions without being logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobTolkemit committed Jul 31, 2019
1 parent 0afc8bd commit c2c28c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Controller/Customer/LoggedInCustomerDetailsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function __construct(

public function __invoke(Request $request): Response
{
if (!$this->loggedInShopUserProvider->isUserLoggedIn()) {
return $this->viewHandler->handle(View::create(null, Response::HTTP_UNAUTHORIZED));
}

$customer = $this->loggedInShopUserProvider->provide()->getCustomer();
Assert::notNull($customer);

Expand Down
4 changes: 4 additions & 0 deletions src/Controller/Customer/UpdateCustomerAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public function __construct(

public function __invoke(Request $request): Response
{
if (!$this->loggedInUserProvider->isUserLoggedIn()) {
return $this->viewHandler->handle(View::create(null, Response::HTTP_UNAUTHORIZED));
}

$validationResults = $this->updateCustomerCommandProvider->validate($request, null, ['sylius_customer_profile_update']);
if (0 !== count($validationResults)) {
return $this->viewHandler->handle(View::create(
Expand Down

0 comments on commit c2c28c3

Please sign in to comment.