protected function loginUser($userLoginOrId)
    {
        if ($userLoginOrId === false) {
            return false;
        }

        $previousUser = $this->repository->getCurrentUser();

        if (is_int($userLoginOrId)) {
            if ($userLoginOrId == $previousUser->id) {
                return $previousUser->id;
            }
            $newUser = $this->repository->getUserService()->loadUser($userLoginOrId);
        } else {
            if ($userLoginOrId == $previousUser->login) {
                return $previousUser->id;
            }
            $newUser = $this->repository->getUserService()->loadUserByLogin($userLoginOrId);
        }

        $this->repository->setCurrentUser($newUser);

        return $previousUser->id;
    }