Will check if article is writing-locked to against blog user.
If NOT - it generate/update lock and return false
If YES - returns userId of the lock holder

@param BlogUserInterface $user
@param ArticleInterface $article
@return mixed
349694
public function isLocked(BlogUserInterface $user, ArticleInterface $article)
    {
        $metaLock = $this->findWritingLockMeta($article);

        if(!$metaLock)
        {
            //no lock detected
            $metaClass = $this->articleMetaClass;
            $metaLock = new $metaClass();
            $metaLock->setArticle($article);

            $this->applyLock($metaLock, $user);

            return false;
        }
        else
        {
            $arrayData = explode(':', $metaLock->getValue());
            $datetimeLock = $arrayData[0];
            $userLock = $arrayData[1];

            if($user->getId() == $userLock)
            {
                //user is holding the lock
                $this->applyLock($metaLock, $user);

                return false;
            }
            else
            {
                if(strtotime(date("Y-m-d H:i:s")) - $datetimeLock >= 30 )
                {
                    //lock expired
                    $this->applyLock($metaLock, $user);

                    return false;
                }
                else
                {
                    //lock is active - edit should be forbidden
                    return $userLock;
                }
            }
        }
    }
787807
public static function login(UserInterface $user): void
    {
        Session::regenerate(false);
        Session::put('wt_user', $user->id());
    }
196570
public function isPublisher(User $user)
    {
        if ($this->publisher) {
            if ($this->publisher->getUser()->getId() === $user->getId()) {
                return true;
            }
        }

        return false;
    }
539290
public function isAnswerAllowed(UserInterface $user, $answer)
    {
        $answerEntity = $this->getEntityManagerAnswer()->getAnswer4UserId($user->getId());

        if (!$answerEntity) {
            return true;
        }

        // @TODO better workflow, with ZendFilter
        $realAnswer = strtolower(trim($answerEntity->getAnswer()));
        $plainAnswer = strtolower(trim($answer));

        return $realAnswer === $plainAnswer;
    }
879200
public function userPage(UserInterface $user): ResponseInterface
    {
        $has_blocks = DB::table('block')
            ->where('user_id', '=', $user->id())
            ->exists();

        if (!$has_blocks) {
            $this->checkDefaultUserBlocksExist();

            // Copy the defaults
            (new Builder(DB::connection()))->from('block')->insertUsing(
                ['user_id', 'location', 'block_order', 'module_name'],
                static function (Builder $query) use ($user): void {
                    $query
                        ->select([DB::raw($user->id()), 'location', 'block_order', 'module_name'])
                        ->from('block')
                        ->where('user_id', '=', -1);
                }
            );
        }

        return $this->viewResponse('user-page', [
            'main_blocks' => $this->userBlocks($user->id(), 'main'),
            'side_blocks' => $this->userBlocks($user->id(), 'side'),
            'title'       => I18N::translate('My page'),
        ]);
    }
172319
private function addTrustedMember(Blog $blog, User $user)
    {
        $member = new Member();
        $member->setBlog($blog);
        $member->setUser($user);
        $member->setTrusted(true);

        $this->om->persist($member);
        $this->om->flush();

        return $member;
    }
729722
public function isAdmitted(UserInterface $user = null)
    {
        if (is_null($user)) {
            return !$this->currentUser() instanceof GuestUser;
        }

        return $user->getIdentifier() === $this->currentUser()->getIdentifier();
    }
32662
protected function article(Article $article = null): ?Article {
        if ($article === null) {
            return $this->article;
        }

        $this->article = $article;

        return $this->article;
    }
294280
public function getArticleUser()
    {
        if ($this->_oUser === null) {
            $this->_oUser = $this->getUser();
        }

        return $this->_oUser;
    }
1152236
protected function addLogSuccess(UserInterface $user)
    {
        $this->userManager->updateUser($user);

        $authLog = $this->createAuthLog();
        $authLog->setSuccess(true);
        $authLog->setUser($user);
        $authLog->setUsername($user->getUsername());

        $this->em->persist($authLog);
        $this->em->flush();
    }
676561
public function isOwnedBy($item, $user = [])
    {
        if (!is_array($item)) {
            $item = $item->toArray();
        }

        if (empty($user)) {
            return false;
        }

        $itemUserId = $item[$this->config('column')];
        $userId = $user['id'];

        if ($itemUserId === $userId) {
            return true;
        }

        return false;
    }
1002548
public static function isAdmin(UserInterface $user = null): bool
    {
        $user = $user ?? self::user();

        return $user->getPreference('canadmin') === '1';
    }
734238
public function store(UserInterface $user): bool
    {
        if($this->regenerate && !session_regenerate_id())
            return false;
        
        $this->session[self::NATIVE_SESSION_USER_IDENTIFIER] = $user;
        
        return true;
    }
116293
public function verifyPassword(UserInterface $user, $password)
    {
        if (!$password) {
            return false;
        }

        $hashedPassword = $user->getHashedPassword();
        if (!$hashedPassword) {
            return false;
        }

        return password_verify($password, $hashedPassword);
    }
302443
public function save(ArticleInterface $article): ArticleInterface
    {
        $data = $this->serializer()->serialize($article);

        if ($article->getId() !== 0) {
            $this->shopware()
                ->put('/api/articles/' . (string)$article->getId(), [], $data);
        } else {
            $response = $this->shopware()->post('/api/articles', [], $data);
            $data = json_decode((string)$response->getBody(), true);
            $dataExists = array_key_exists('data', $data) && is_array($data['data']);
            if (!$dataExists || !array_key_exists('id', $data['data'])) {
                throw new \LogicException('Article could not be created! ' . (string)$response->getBody());
            }
            $article->setId((int)$data['data']['id']);
        }

        return $article;
    }
1065815
public function delete($user, Thread $thread)
    {
        return Gate::allows('deleteThreads', $thread->category) || $user->getKey() === $thread->author_id;
    }
234987
public function refreshUser(UserInterface $user)
    {
        $username                     = $user->getUsername();
        $this->cachedUsers[$username] = $this->userProvider->refreshUser($user);
        return $this->cachedUsers[$username];
    }