Assign the Cart stored in session to the logged Customer.

When a user has successfully logged in, a check is needed
to see if a Cart was created in session when she was not
logged.

@param AuthenticationEvent $event Event
187289
public function onAuthenticationSuccess(AuthenticationEvent $event)
    {
        $loggedUser = $event
            ->getAuthenticationToken()
            ->getUser();

        $cart = $this
            ->cartWrapper
            ->get();

        if (
            ($loggedUser instanceof CustomerInterface) &&
            ($cart instanceof CartInterface && $cart->getId())
        ) {
            /*
             * We assume that a cart with an ID is
             * not a pristine entity coming from a
             * factory method. (i.e. has already been
             * flushed)
             */
            $cart->setCustomer($loggedUser);

            $this->cartManager->flush($cart);
        }
    }
513289
public function preCreate(CreateEvent $event)
    {
        /** @var Group $role */
        $object = $event->getObject();
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof User) {
            $object->setUser($user);
        } else {
            $object->setUser($this->userManager->getDefaultClarolineUser());
        }
    }
566098
public function handle(Authenticating $event)
    {
        $username = $this->getPrefix().$event->username.$this->getSuffix();

        Log::info("User '{$event->user->getCommonName()}' is authenticating with username: '{$username}'");
    }
828443
public function onAfterLogin(UserEvent $event)
    {
        if (!$this->identity->is_api_user) {
            Yii::$app->language = $this->getInterfaceLanguage();
        }
    }
1144217
public function beforeSave(Event $event)
    {
        if (isset($this->_controller()->request->data['password'])) {
            $password = $this->_controller()->request->data['password'];
            $event->subject->entity['password'] = $password;
        }
    }
1181534
public function onUserEntityPreSave(StorageEvent $event)
    {
        /** @var Entity\Users $entityRecord */
        $entityRecord = $event->getContent();

        if ($entityRecord instanceof Entity\Users) {
            $this->passwordHash($entityRecord);
        }
    }
810863
public function onAuthenticate(AnEvent $event)
    {
        $credentials = $event->credentials;
        $response = $event->response;

        if (isset($credentials->username) && isset($credentials->password)) {
            return;
        }

        if (! (isset($credentials->oauth_token) && isset($credentials->oauth_handler))) {
            return;
        }

        try {
            extract($credentials, EXTR_SKIP);

            //if oatuh secret not set then set it to null
            if (empty($oauth_secret)) {
                $oauth_secret = '';
            }

            //lets get the api
            $api = ComConnectHelperApi::getApi($oauth_handler);
            $api->setToken($oauth_token, $oauth_secret);

            //if we can get the logged in user then
            //the user is authenticated
            if ($profile_id = $api->getUser()->id) {
                //lets find a valid sesison
                //lets be strict and make sure all the values match
                $session = AnService::get('repos:connect.session')->find(array(
                            'owner.type' => 'com:people.domain.entity.person',
                            'profileId' => $profile_id,
                            'tokenKey' => $oauth_token,
                            'api' => $oauth_handler,
                        ));

                if (! is_null($session)) {
                    $response->status = ComPeopleAuthentication::STATUS_SUCCESS;
                    $response->username = $session->owner->username;
                    $response->password = '';
                    $reponse->email = '';
                    $response->error_message = '';
                }
            }

        } catch (Exception $e) {
            error_log($e->getMessage());
        }
    }
1278686
public function addLogRecord($event) {
        /**
         * If logging is enabled
         */
        $module = \Yii::$app->getModule('cart');
        if ($module->enableLog) {

            $message = "UserId: $event->id";

            Yii::info($message, $event->name);
        }
    }
1278690
public function handle(TenantIdentified $event)
    {
        if (!session('tenant')) {
            session(['tenant' => $event->tenant->id]);
        }

        app(Manager::class)->setTenant($event->tenant);
        $this->db->createConnection($event->tenant);
    }
372215
public function preCreate(CreateEvent $event)
    {
        /** @var Group $role */
        $group = $event->getObject();
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof User) {
            $group->addOrganization($user->getMainOrganization());
        }
    }
961101
public function auth(AuthEvent $event)
    {
        if (isset($this->logger)) {
            $operation = get_class($event);

            $connection = $event->getConnection();

            $message = "LDAP ({$connection->getHost()})"
                . " - Connection: {$connection->getName()}"
                . " - Operation: {$operation}"
                . " - Username: {$event->getUsername()}";

            $result = null;
            $type = 'info';

            if (is_a($event, Failed::class)) {
                $type = 'warning';
                $result = " - Reason: {$connection->getLastError()}";
            }
            
            $this->logger->$type($message.$result);
        }
    }
368508
protected function fireCreatedEvent(Authenticatable $user, Token $token)
    {
        if ($this->createdEvent === null || !class_exists($this->createdEvent)) {
            return;
        }

        event(new $this->createdEvent($user, $token));
    }
600668
public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event)
    {
        $data = $event->getData();
        $data['user'] = $event->getUser()->getUsername();

        $event->setData($data);
    }
286786
public function rememberCheckoutUuids(PersistEvent $event)
    {
        if (!$this->support($event->getDocument())) {
            return;
        }

        $this->checkoutUuids[] = $event->getNode()->getIdentifier();
    }
575746
def authenticationrequest(self, event):
        

        if event.sock.getpeername()[0] in self.failing_clients:
            self.log('Client failed a login and has to wait', lvl=debug)
            return

        if event.auto:
            self._handle_autologin(event)
        else:
            self._handle_login(event)
918334
public function beforeRender(Event $event) {
		if (in_array('Captcha.Captcha', $this->controller->helpers) || isset($this->controller->helpers['Captcha.Captcha'])) {
			return;
		}

		$this->controller->helpers[] = 'Captcha.Captcha';
	}
680550
public function verifyToken(Event $event)
    {
        $event->subject->verified = TableRegistry::get('Muffin/Tokenize.Tokens')
            ->verify($event->subject->token);
    }