hasPrivilege example

->leftJoin('users.attribute', 'attribute')
            ->where('users.id = ?1')
            ->setParameter(1, $id);

        /** @var UserModel|array|null $user */
        $user = $builder->getQuery()->getOneOrNullResult($this->getResultMode());

        if (!$user) {
            throw new NotFoundException(sprintf('User by id %s not found', $id));
        }

        if (!$this->hasPrivilege('create', 'usermanager')
            && !$this->hasPrivilege('update', 'usermanager')) {
            if (\is_array($user)) {
                unset($user['apiKey']$user['sessionId']$user['password']$user['encoder']);
            } else {
                $user->setApiKey('');
                $user->setSessionId('');
                $user->setPassword('');
                $user->setEncoder('');
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.