Example #1
0
 /**
  * @param $request
  * @param $session
  *
  * @return array
  */
 protected function getRememberMeCustomer(Request $request, Session $session, EventDispatcher $dispatcher)
 {
     // try to get the remember me cookie
     $cookieCustomerName = ConfigQuery::read('customer_remember_me_cookie_name', 'crmcn');
     $cookie = $this->getRememberMeKeyFromCookie($request, $cookieCustomerName);
     if (null !== $cookie) {
         // try to log
         $authenticator = new CustomerTokenAuthenticator($cookie);
         try {
             // If have found a user, store it in the security context
             $user = $authenticator->getAuthentifiedUser();
             $session->setCustomerUser($user);
             $dispatcher->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($user));
         } catch (TokenAuthenticationException $ex) {
             // Clear the cookie
             $this->clearRememberMeCookie($cookieCustomerName);
         }
     }
 }