コード例 #1
1
 function it_logs_user_out(SessionInterface $session, CookieSetterInterface $cookieSetter)
 {
     $session->set('_security_shop', null)->shouldBeCalled();
     $session->save()->shouldBeCalled();
     $session->getName()->willReturn('MOCKEDSID');
     $session->getId()->willReturn('xyzc123');
     $cookieSetter->setCookie('MOCKEDSID', 'xyzc123')->shouldBeCalled();
     $this->logOut();
 }
コード例 #2
0
ファイル: SecurityService.php プロジェクト: ahmadrabie/Sylius
 /**
  * @param UserInterface $user
  */
 private function logInUser(UserInterface $user)
 {
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles());
     $this->session->set($this->sessionTokenVariable, serialize($token));
     $this->session->save();
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }
コード例 #3
0
 function it_does_not_log_user_in_if_user_was_not_found(UserRepositoryInterface $userRepository, SessionInterface $session, CookieSetterInterface $cookieSetter)
 {
     $userRepository->findOneBy(['username' => '*****@*****.**'])->willReturn(null);
     $session->set(Argument::cetera())->shouldNotBeCalled();
     $session->save()->shouldNotBeCalled();
     $cookieSetter->setCookie(Argument::cetera())->shouldNotBeCalled();
     $this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', ['*****@*****.**']);
 }
コード例 #4
0
 /**
  * @param TokenInterface $token
  */
 private function setToken(TokenInterface $token)
 {
     $serializedToken = serialize($token);
     $this->session->set($this->sessionTokenVariable, $serializedToken);
     $this->session->save();
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }
コード例 #5
0
 function it_sets_channel_as_current(CookieSetterInterface $cookieSetter, ChannelInterface $channel)
 {
     $channel->getCode()->willReturn('CHANNEL_CODE');
     $cookieSetter->setCookie('_channel_code', 'CHANNEL_CODE')->shouldBeCalled();
     $this->setChannel($channel);
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function setChannel(ChannelInterface $channel)
 {
     $this->cookieSetter->setCookie('_channel_code', $channel->getCode());
 }
コード例 #7
0
ファイル: SecurityService.php プロジェクト: okwinza/Sylius
 /**
  * @param string $token
  */
 private function restorePreviousSessionToken($token)
 {
     $this->setSerializedToken($token);
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }