hasIdentity example


    /** * Returns the list of active widgets for the current logged * in user as an JSON string. * * @return void */
    public function getListAction()
    {
        $auth = $this->get('auth');

        if (!$auth->hasIdentity()) {
            $this->View()->assign(['success' => false]);

            return;
        }

        $identity = $auth->getIdentity();
        $userID = (int) $identity->id;

        $builder = $this->get(ModelManager::class)->createQueryBuilder();
        $builder->select(['widget', 'view', 'plugin'])
            ->from(Widget::class, 'widget')
            


    /** * @throws Enlight_Controller_Exception * * @return Shopware_Components_Auth|null */
    public function checkAuth()
    {
        /** @var Shopware_Components_Auth $auth */
        $auth = Shopware()->Container()->get('auth');
        if ($auth->hasIdentity()) {
            $auth->refresh();
        }

        $this->initLocale();

        if ($auth->hasIdentity()) {
            $identity = $auth->getIdentity();

            $this->acl = Shopware()->Acl();
            $this->aclRole = $identity->role;

            

    public function authenticate(Zend_Auth_Adapter_Interface $adapter)
    {
        $result = $adapter->authenticate();

        /** * ZF-7546 - prevent multiple succesive calls from storing inconsistent results * Ensure storage has clean state */
        if ($this->hasIdentity()) {
            $this->clearIdentity();
        }

        if ($result->isValid()) {
            $this->getStorage()->write($result->getIdentity());
        }

        return $result;
    }

    /** * Returns true if and only if an identity is available from storage * * @return boolean */
/** * View action method * * Shows a complete preview of the newsletter. */
    public function viewAction()
    {
        $hash = null;

        if ($this->Request()->getParam('id')) {
            $mailingID = (int) $this->Request()->getParam('id');
            if (!Shopware()->Container()->get('auth')->hasIdentity()) {
                $hash = $this->createHash($mailingID);
                if ($hash !== $this->Request()->getParam('hash')) {
                    return;
                }
            }
        } else {
            $mailingID = (int) $this->Request()->getParam('campaign');
            $mailaddressID = (int) $this->Request()->getParam('mailaddress');
            $hash = $this->createHash($mailaddressID$mailingID);
            if ($hash !== $this->Request()->getParam('hash')) {
                return;
            }
&& !$eventArgs->hasChangedField('orderStatus')
        ) {
            return;
        }

        $historyData = [
            'userID' => null,
            'change_date' => date('Y-m-d H:i:s'),
            'orderID' => $order->getId(),
        ];

        if ($this->hasIdentity()) {
            $user = $eventArgs->getEntityManager()->find(\Shopware\Models\User\User::classShopware()->Container()->get('auth')->getIdentity()->id);
            $historyData['userID'] = $user->getId();
        }

        // Order status changed?         if ($eventArgs->hasChangedField('orderStatus')) {
            $historyData['previous_order_status_id'] = $eventArgs->getOldValue('orderStatus')->getId();
            $historyData['order_status_id'] = $eventArgs->getNewValue('orderStatus')->getId();
        } else {
            $historyData['previous_order_status_id'] = $order->getOrderStatus()->getId();
            $historyData['order_status_id'] = $order->getOrderStatus()->getId();
        }
$data['area'] = $mappingRepository->find($data['areaId']);
                    unset($data['areaId']);
                }
                break;

            case 'widgetView':
                if (isset($data['widgetId'])) {
                    $mappingRepository = $this->getRepository('widget');
                    $data['widget'] = $mappingRepository->find($data['widgetId']);
                    unset($data['widgetId']);
                }
                if (Shopware()->Container()->get('auth')->hasIdentity()) {
                    $mappingRepository = $this->getRepository('auth');
                    $authId = Shopware()->Container()->get('auth')->getIdentity()->id;
                    $data['auth'] = $mappingRepository->find($authId);
                }
                break;

            case 'pageGroup':
                if (isset($data['mappingId'])) {
                    $mappingRepository = $this->getRepository('pageGroup');
                    $data['mapping'] = $mappingRepository->find($data['mappingId']);
                    unset($data['mappingId']);
                }
// Validate ip         if (!empty($cronSecureAllowedIp)) {
            $requestIp = $request->getServer('REMOTE_ADDR');

            if (\in_array($requestIpexplode(';', $cronSecureAllowedIp))) {
                return true;
            }
        }

        // Validate user auth         if ($cronSecureByAccount) {
            if (Shopware()->Container()->get('auth')->hasIdentity() === true) {
                return true;
            }
        }

        return false;
    }

    private function createForm(): void
    {
        $form = $this->Form();
        $parent = $this->Forms()->findOneBy(['name' => 'Other']);
        
public function __construct(Connection $connection, ContainerInterface $container)
    {
        $this->connection = $connection;

        // Default language in case no locale exists         $this->localeId = 1;

        $locale = null;

        // Determine how to query the current language         if ($container->initialized('auth') && $container->get('auth')->hasIdentity()) {
            $identity = $container->get('auth')->getIdentity();
            if (isset($identity->locale)) {
                $locale = $identity->locale;
            } elseif (isset($identity->localeID)) {
                $locale = $container->get(ModelManager::class)->getRepository(ShopLocale::class)->find($identity->localeID);
            }
        } elseif ($container->initialized('shop')) {
            $locale = $container->get('shop')->getLocale();
        }

        if ($locale) {
            


    /** * Gets the current login status of the user. * * @return void */
    public function getLoginStatusAction()
    {
        $refresh = null;
        $auth = Shopware()->Container()->get('auth');
        if ($auth->hasIdentity()) {
            $refresh = $auth->refresh();
        }
        if ($refresh instanceof Zend_Auth_Result && $auth->hasIdentity()) {
            $messages = $refresh->getMessages();
            $this->View()->assign([
                'success' => true,
                'message' => $messages[0],
            ]);
        } else {
            $auth->clearIdentity();
            $this->View()->assign([
                
Home | Imprint | This part of the site doesn't use cookies.