Журналы:
Код: Выделить всё
NOTICE: PHP message: [info] Matched route "auth_discord_login".
NOTICE: PHP message: [debug] Checking for authenticator support.
NOTICE: PHP message: [debug] Checking support on authenticator.
NOTICE: PHP message: [debug] Checking support on authenticator.
NOTICE: PHP message: [debug] Remember-me cookie detected.
NOTICE: PHP message: [debug] Read existing security token from the session.
...
NOTICE: PHP message: [warning] Username could not be found in the selected user provider.
NOTICE: PHP message: [debug] Token was deauthenticated after trying to refresh it.
NOTICE: PHP message: [debug] Authenticator does not support the request.
NOTICE: PHP message: [debug] Clearing remember-me cookie.
NOTICE: PHP message: [info] Authenticator failed.
NOTICE: PHP message: [debug] Clearing remember-me cookie.
Код: Выделить всё
security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
users:
entity:
class: 'App\User\Domain\User'
property: 'username'
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
remember_me:
secret: '%kernel.secret%'
always_remember_me: true
lifetime: 2592000 # 1 month in seconds
path: / # cookie path
signature_properties: ['username']
token_provider:
doctrine: true
lazy: true
provider: users
custom_authenticators:
- App\User\Application\Oauth2\DiscordAuthenticatorService
logout:
path: auth_discord_app_logout
target: app_index
https://gist.github.com/LevPrav999/c2ab ... 40eb55b0a6
Панель отладки:Перед обновлением:
показывается идентификатор пользователя.
После обновления:
не отображается.
Мой пользователь. Класс .php:
Код: Выделить всё
#[ORM\Entity(repositoryClass: BotRepositoryInterface::class)]
#[ORM\Table(name: 'users')]
#[ORM\HasLifecycleCallbacks]
class User implements UserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $username;
#[ORM\Column(type: 'string', length: 250)]
#[AssertConstraints\NotBlank]
private ?string $description = "";
#[ORM\Column(type: 'json')]
#[AssertConstraints\NotBlank]
private array $roles = [];
/**
* @param string|null $discordId
*/
public function __construct(?string $discordId)
{
$this->username = $discordId;
}
public function getId(): ?int
{
return $this->id;
}
public function setId(?int $id): void
{
$this->id = $id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(?string $discordId): void
{
$this->username = $discordId;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): void
{
$this->description = $description;
}
public function getRoles(): array
{
$roles = $this->roles;
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
public function getUserIdentifier(): string
{
return $this->username;
}
/** @see \Serializable::serialize() */
public function serialize(): string
{
return serialize(array(
$this->id,
$this->username,
$this->description,
$this->roles
));
}
/** @see \Serializable::unserialize() */
public function unserialize(string $serialized): void
{
list (
$this->id,
$this->username,
$this->description,
$this->roles
) = unserialize($serialized);
}
}
Я попробовал изменить класс User, добавив сериализацию
Подробнее здесь: https://stackoverflow.com/questions/785 ... s-reloaded
Мобильная версия