且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

symfony 3.4“不推荐刷新未经身份验证的用户"

更新时间:2023-12-01 16:01:16

认证失效的问题2017-12-07 15:48:24] security.DEBUG:尝试刷新令牌后,令牌被取消身份验证.{"username":"aaa","provider":"Symfony\\Bridge\\Doctrine\\Security\\User\\EntityUserProvider"} []

是,我没有遵循文档https://symfony.com/doc/3.4/security/entity_provider.html#create-your-user-entity 它说,应该还有密码字段(我不会让 symfony 将凭据放在磁盘上太多次了).在 symfony 3.3 中没问题,在 symfony 3.4 中该字段必须存在......

was, that I was not following the documentation https://symfony.com/doc/3.4/security/entity_provider.html#create-your-user-entity which says, that there should be also password field (I would not let symfony to put credentials on disk too many times). In symfony 3.3 it was ok, in symfony 3.4 the field must be present ...

diff --git a/src/GuserBundle/Entity/User.php b/src/GuserBundle/Entity/User.php
index 4adeaf9..b1b33fd 100644
--- a/src/GuserBundle/Entity/User.php
+++ b/src/GuserBundle/Entity/User.php
@@ -152,13 +152,13 @@ class User implements AdvancedUserInterface, \Serializable {
        /** @see \Serializable::serialize() */
        public function serialize() {
-               return serialize(array($this->id, $this->username, $this->active,));
+               return serialize(array($this->id, $this->username, $this->password, $this->active, $this->locked));
        }
        /** @see \Serializable::unserialize() */
        public function unserialize($serialized) {
-               list($this->id, $this->username, $this->active,) = unserialize($serialized);
+               list($this->id, $this->username, $this->password, $this->active, $this->locked) = unserialize($serialized);
        }