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

InvoiceVoter does not support other instances of Sylius\Component\User\Model\UserInterface #298

Open
j92 opened this issue Nov 8, 2022 · 1 comment
Labels
DX Issues and PRs aimed at improving Developer eXperience. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).

Comments

@j92
Copy link
Contributor

j92 commented Nov 8, 2022

In one of my projects, we created a new GuestUser that implements a Sylius\Component\User\Model\UserInterface. When I tried to access an invoice with that user, the Sylius\InvoicingPlugin\Security\Voter\InvoiceVoter denied access, because it only handles AdminUserInterface and ShopUserInterface. The AdminUserInterface check seems fine, but perhaps we can consider to loosen the ShopUserInterface type check to something like a type check for Sylius\Component\Customer\Model\CustomerAwareInterface as the Customer is the only data we need in that place?

if ($user instanceof Sylius\Component\Customer\Model\CustomerAwareInterface) {
    $customer = $user->getCustomer();

    Assert::isInstanceOf($customer, CustomerInterface::class);

    return null !== $this->orderRepository->findOneByNumberAndCustomer($invoice->orderNumber(), $customer);
}

What do you think?

@GSadee GSadee added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). DX Issues and PRs aimed at improving Developer eXperience. labels Feb 16, 2023
GSadee added a commit that referenced this issue Feb 21, 2023
…(j92)

This PR was merged into the main branch.

Discussion
----------

See issue: #298

Commits
-------

c84a9d4 Loosen type check for user, to handle more types of users
@diimpp
Copy link
Member

diimpp commented Jul 8, 2023

Looks like issue is fixed and can be closed. @j92 @GSadee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues and PRs aimed at improving Developer eXperience. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

No branches or pull requests

3 participants