forked from wallabag/wallabag
Move User entity to Core
This commit is contained in:
@ -10,8 +10,8 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\UserBundle\Repository\UserRepository;
|
||||
|
||||
class CleanDuplicatesCommand extends Command
|
||||
|
||||
@ -8,9 +8,9 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Helper\UrlHasher;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\UserBundle\Repository\UserRepository;
|
||||
|
||||
class GenerateUrlHashesCommand extends Command
|
||||
|
||||
@ -22,7 +22,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
|
||||
use Wallabag\CoreBundle\Entity\InternalSetting;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\UserBundle\Repository\UserRepository;
|
||||
|
||||
class ShowUserCommand extends Command
|
||||
|
||||
@ -9,8 +9,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Helper\RuleBasedTagger;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\UserBundle\Repository\UserRepository;
|
||||
|
||||
class TagAllCommand extends Command
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as BaseAbstractController;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
abstract class AbstractController extends BaseAbstractController
|
||||
{
|
||||
|
||||
@ -12,10 +12,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Wallabag\CoreBundle\Entity\Annotation;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Form\Type\EditAnnotationType;
|
||||
use Wallabag\CoreBundle\Form\Type\NewAnnotationType;
|
||||
use Wallabag\CoreBundle\Repository\AnnotationRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
class AnnotationController extends AbstractFOSRestController
|
||||
{
|
||||
|
||||
@ -13,9 +13,9 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Helper\PreparePagerForEntries;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
class FeedController extends AbstractController
|
||||
{
|
||||
@ -31,7 +31,7 @@ class FeedController extends AbstractController
|
||||
*
|
||||
* @Route("/feed/{username}/{token}/unread/{page}", name="unread_feed", defaults={"page"=1, "_format"="xml"})
|
||||
*
|
||||
* @ParamConverter("user", class="Wallabag\UserBundle\Entity\User", converter="username_feed_token_converter")
|
||||
* @ParamConverter("user", class="Wallabag\CoreBundle\Entity\User", converter="username_feed_token_converter")
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@ -45,7 +45,7 @@ class FeedController extends AbstractController
|
||||
*
|
||||
* @Route("/feed/{username}/{token}/archive/{page}", name="archive_feed", defaults={"page"=1, "_format"="xml"})
|
||||
*
|
||||
* @ParamConverter("user", class="Wallabag\UserBundle\Entity\User", converter="username_feed_token_converter")
|
||||
* @ParamConverter("user", class="Wallabag\CoreBundle\Entity\User", converter="username_feed_token_converter")
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@ -59,7 +59,7 @@ class FeedController extends AbstractController
|
||||
*
|
||||
* @Route("/feed/{username}/{token}/starred/{page}", name="starred_feed", defaults={"page"=1, "_format"="xml"})
|
||||
*
|
||||
* @ParamConverter("user", class="Wallabag\UserBundle\Entity\User", converter="username_feed_token_converter")
|
||||
* @ParamConverter("user", class="Wallabag\CoreBundle\Entity\User", converter="username_feed_token_converter")
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@ -73,7 +73,7 @@ class FeedController extends AbstractController
|
||||
*
|
||||
* @Route("/feed/{username}/{token}/all/{page}", name="all_feed", defaults={"page"=1, "_format"="xml"})
|
||||
*
|
||||
* @ParamConverter("user", class="Wallabag\UserBundle\Entity\User", converter="username_feed_token_converter")
|
||||
* @ParamConverter("user", class="Wallabag\CoreBundle\Entity\User", converter="username_feed_token_converter")
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@ -87,7 +87,7 @@ class FeedController extends AbstractController
|
||||
*
|
||||
* @Route("/feed/{username}/{token}/tags/{slug}/{page}", name="tag_feed", defaults={"page"=1, "_format"="xml"})
|
||||
*
|
||||
* @ParamConverter("user", class="Wallabag\UserBundle\Entity\User", converter="username_feed_token_converter")
|
||||
* @ParamConverter("user", class="Wallabag\CoreBundle\Entity\User", converter="username_feed_token_converter")
|
||||
* @ParamConverter("tag", options={"mapping": {"slug": "slug"}})
|
||||
*
|
||||
* @return Response
|
||||
|
||||
@ -12,10 +12,10 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Wallabag\CoreBundle\Entity\SiteCredential;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Form\Type\SiteCredentialType;
|
||||
use Wallabag\CoreBundle\Helper\CryptoProxy;
|
||||
use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* SiteCredential controller.
|
||||
|
||||
@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\UserBundle\Form\NewUserType;
|
||||
use Wallabag\UserBundle\Form\SearchUserType;
|
||||
use Wallabag\UserBundle\Form\UserType;
|
||||
|
||||
@ -7,7 +7,7 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\CoreBundle\Entity\Annotation;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class AnnotationFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class ConfigFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class EntryFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class IgnoreOriginUserRuleFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
|
||||
@ -8,8 +8,8 @@ use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Wallabag\CoreBundle\Entity\SiteCredential;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Helper\CryptoProxy;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface
|
||||
{
|
||||
|
||||
@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class UserFixtures extends Fixture
|
||||
{
|
||||
|
||||
@ -10,7 +10,6 @@ use JMS\Serializer\Annotation\SerializedName;
|
||||
use JMS\Serializer\Annotation\VirtualProperty;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Annotation.
|
||||
@ -81,7 +80,7 @@ class Annotation
|
||||
/**
|
||||
* @Exclude
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
|
||||
* @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\User")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JMS\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Config.
|
||||
@ -170,7 +169,7 @@ class Config
|
||||
private $customCSS;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config")
|
||||
* @ORM\OneToOne(targetEntity="Wallabag\CoreBundle\Entity\User", inversedBy="config")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@ use JMS\Serializer\Annotation\XmlRoot;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
|
||||
use Wallabag\CoreBundle\Helper\UrlHasher;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Entry.
|
||||
@ -289,7 +288,7 @@ class Entry
|
||||
/**
|
||||
* @Exclude
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries")
|
||||
* @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\User", inversedBy="entries")
|
||||
*
|
||||
* @Groups({"export_all"})
|
||||
*/
|
||||
|
||||
@ -5,7 +5,6 @@ namespace Wallabag\CoreBundle\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* SiteCredential.
|
||||
@ -67,7 +66,7 @@ class SiteCredential
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="siteCredentials")
|
||||
* @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\User", inversedBy="siteCredentials")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
|
||||
411
src/Wallabag/CoreBundle/Entity/User.php
Normal file
411
src/Wallabag/CoreBundle/Entity/User.php
Normal file
@ -0,0 +1,411 @@
|
||||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use FOS\UserBundle\Model\User as BaseUser;
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\Groups;
|
||||
use JMS\Serializer\Annotation\XmlRoot;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use OpenApi\Annotations as OA;
|
||||
use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
|
||||
use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface as EmailTwoFactorInterface;
|
||||
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface as GoogleTwoFactorInterface;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Wallabag\ApiBundle\Entity\Client;
|
||||
use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
|
||||
|
||||
/**
|
||||
* User.
|
||||
*
|
||||
* @XmlRoot("user")
|
||||
* @ORM\Entity(repositoryClass="Wallabag\UserBundle\Repository\UserRepository")
|
||||
* @ORM\Table(name="`user`")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*
|
||||
* @UniqueEntity("email")
|
||||
* @UniqueEntity("username")
|
||||
*/
|
||||
class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorInterface, BackupCodeInterface
|
||||
{
|
||||
use EntityTimestampsTrait;
|
||||
|
||||
/** @Serializer\XmlAttribute */
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="The unique numeric id of the user",
|
||||
* type="int",
|
||||
* example=12,
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api", "user_api_with_client"})
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="name", type="text", nullable=true)
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="The personal Name of the user",
|
||||
* type="string",
|
||||
* example="Walla Baggger",
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api", "user_api_with_client"})
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="The unique username of the user",
|
||||
* type="string",
|
||||
* example="wallabag",
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api", "user_api_with_client"})
|
||||
*/
|
||||
protected $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="E-mail address of the user",
|
||||
* type="string",
|
||||
* example="wallabag@wallabag.io",
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api", "user_api_with_client"})
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="created_at", type="datetime")
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="Creation date of the user account. (In ISO 8601 format)",
|
||||
* type="string",
|
||||
* example="2023-06-27T19:25:44+0000",
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api", "user_api_with_client"})
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="updated_at", type="datetime")
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="Update date of the user account. (In ISO 8601 format)",
|
||||
* type="string",
|
||||
* example="2023-06-27T19:37:30+0000",
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api", "user_api_with_client"})
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\Entry", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
protected $entries;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection&iterable<\Wallabag\CoreBundle\Entity\SiteCredential>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\SiteCredential", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
protected $siteCredentials;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection&iterable<\Wallabag\ApiBundle\Entity\Client>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
protected $clients;
|
||||
|
||||
/**
|
||||
* @see getFirstClient() below
|
||||
*
|
||||
* @OA\Property(
|
||||
* description="Default client created during user registration. Used for further authorization",
|
||||
* ref=@Model(type=Client::class, groups={"user_api_with_client"})
|
||||
* )
|
||||
*
|
||||
* @Groups({"user_api_with_client"})
|
||||
* @Accessor(getter="getFirstClient")
|
||||
*/
|
||||
protected $default_client;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $authCode;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="googleAuthenticatorSecret", type="string", nullable=true)
|
||||
*/
|
||||
private $googleAuthenticatorSecret;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
*/
|
||||
private $backupCodes;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $emailTwoFactor = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->entries = new ArrayCollection();
|
||||
$this->roles = ['ROLE_USER'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function addEntry(Entry $entry)
|
||||
{
|
||||
$this->entries[] = $entry;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection<Entry>
|
||||
*/
|
||||
public function getEntries()
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config.
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setConfig(Config $config = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get config.
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailTwoFactor()
|
||||
{
|
||||
return $this->emailTwoFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $emailTwoFactor
|
||||
*/
|
||||
public function setEmailTwoFactor($emailTwoFactor)
|
||||
{
|
||||
$this->emailTwoFactor = $emailTwoFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the user config form to be "like" the email option.
|
||||
*/
|
||||
public function isGoogleTwoFactor()
|
||||
{
|
||||
return $this->isGoogleAuthenticatorEnabled();
|
||||
}
|
||||
|
||||
public function isEmailAuthEnabled(): bool
|
||||
{
|
||||
return $this->emailTwoFactor;
|
||||
}
|
||||
|
||||
public function getEmailAuthCode(): string
|
||||
{
|
||||
return $this->authCode;
|
||||
}
|
||||
|
||||
public function setEmailAuthCode(string $authCode): void
|
||||
{
|
||||
$this->authCode = $authCode;
|
||||
}
|
||||
|
||||
public function getEmailAuthRecipient(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function isGoogleAuthenticatorEnabled(): bool
|
||||
{
|
||||
return $this->googleAuthenticatorSecret ? true : false;
|
||||
}
|
||||
|
||||
public function getGoogleAuthenticatorUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function getGoogleAuthenticatorSecret(): string
|
||||
{
|
||||
return $this->googleAuthenticatorSecret;
|
||||
}
|
||||
|
||||
public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): void
|
||||
{
|
||||
$this->googleAuthenticatorSecret = $googleAuthenticatorSecret;
|
||||
}
|
||||
|
||||
public function setBackupCodes(array $codes = null)
|
||||
{
|
||||
$this->backupCodes = $codes;
|
||||
}
|
||||
|
||||
public function getBackupCodes()
|
||||
{
|
||||
return $this->backupCodes;
|
||||
}
|
||||
|
||||
public function isBackupCode(string $code): bool
|
||||
{
|
||||
return false === $this->findBackupCode($code) ? false : true;
|
||||
}
|
||||
|
||||
public function invalidateBackupCode(string $code): void
|
||||
{
|
||||
$key = $this->findBackupCode($code);
|
||||
|
||||
if (false !== $key) {
|
||||
unset($this->backupCodes[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function addClient(Client $client)
|
||||
{
|
||||
$this->clients[] = $client;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection<Client>
|
||||
*/
|
||||
public function getClients()
|
||||
{
|
||||
return $this->clients;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used by the API when creating a new user it'll also return the first client (which was also created at the same time).
|
||||
*
|
||||
* @return Client|false
|
||||
*/
|
||||
public function getFirstClient()
|
||||
{
|
||||
if (!empty($this->clients)) {
|
||||
return $this->clients->first();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to find a backup code from the list of backup codes of the current user.
|
||||
*
|
||||
* @param string $code Given code from the user
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private function findBackupCode(string $code)
|
||||
{
|
||||
foreach ($this->backupCodes as $key => $backupCode) {
|
||||
// backup code are hashed using `password_hash`
|
||||
// see ConfigController->otpAppAction
|
||||
if (password_verify($code, $backupCode)) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\Event\Listener;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Stores the locale of the user in the session after the login.
|
||||
|
||||
@ -15,8 +15,8 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
class EntryFilterType extends AbstractType
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class UserInformationType extends AbstractType
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest.
|
||||
|
||||
@ -6,7 +6,7 @@ use Pagerfanta\Adapter\AdapterInterface;
|
||||
use Pagerfanta\Adapter\NullAdapter;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class PreparePagerForEntries
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ use GuzzleHttp\Psr7\Uri;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Manage redirections to avoid redirecting to empty routes.
|
||||
|
||||
@ -8,9 +8,9 @@ use RulerZ\RulerZ;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
use Wallabag\CoreBundle\Entity\TaggingRule;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
use Wallabag\CoreBundle\Repository\TagRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
class RuleBasedTagger
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\UserBundle\Repository\UserRepository;
|
||||
|
||||
/**
|
||||
@ -50,7 +50,7 @@ class UsernameFeedTokenConverter implements ParamConverterInterface
|
||||
$em = $this->registry->getManagerForClass($configuration->getClass());
|
||||
|
||||
// Check, if class name is what we need
|
||||
if (null !== $em && 'Wallabag\UserBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) {
|
||||
if (null !== $em && 'Wallabag\CoreBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@ use Twig\Extension\AbstractExtension;
|
||||
use Twig\Extension\GlobalsInterface;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
use Wallabag\CoreBundle\Repository\TagRepository;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
class WallabagExtension extends AbstractExtension implements GlobalsInterface
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user