GithubHelp home page GithubHelp logo

Comments (4)

shopware-issue-bot avatar shopware-issue-bot commented on June 10, 2024

We found the following existing issues which may help or are related to your topic:

from shopware.

shyim avatar shyim commented on June 10, 2024

Maybe we need to move this into the Login Route? 🤔

$newContext = $this->salesChannelContextService->get(
new SalesChannelContextServiceParameters(
$context->getSalesChannelId(),
$token,
$context->getLanguageId(),
$context->getCurrencyId(),
$context->getDomainId(),
$context->getContext()
)
);
// Update the sales channel context for CacheResponseSubscriber
$request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT, $newContext);

from shopware.

nyze2oo9 avatar nyze2oo9 commented on June 10, 2024

I can confirm, that it work with a RouteDecorator for the LoginRoute

  #[Route(path: '/store-api/account/login', name: 'store-api.account.login', methods: ['POST'])]
  public function login(RequestDataBag $data, SalesChannelContext $context): ContextTokenResponse
  {
    $result = $this->decorated->login($data, $context);

    $newContext = $this->salesChannelContextService->get(
      new SalesChannelContextServiceParameters(
        $context->getSalesChannelId(),
        $result->getToken(),
        $context->getLanguageId(),
        $context->getCurrencyId(),
        $context->getDomainId(),
        $context->getContext()
      )
    );
    $request = $this->requestStack->getCurrentRequest();
    $request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT, $newContext);

    return $result;
  }

One thing I don't like is the fact that I had to inject the RequestStack into the decorator because the login method only gets passed the RequestDataBag.

If desired, I can work on a PR in the next few days to get this fix into the original route and get rid of the decorator?

from shopware.

shyim avatar shyim commented on June 10, 2024

sounds good :)

I would also check that getCurrentRequest is not null, before using it

from shopware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.