zizoujab
zizoujab

Reputation: 7800

Symfony2 security : get username when refreshing user

Why the entity provider in it's refreshUser method returns a user object having NULL as username instead of the actual username ?

public function refreshUser(UserInterface $user)
{
    $class = get_class($user);
    if (!$this->supportsClass($class)) {
        throw new UnsupportedUserException(
            sprintf(
                'Instances of "%s" are not supported.',
                $class
            )
        );
    }
    var_dump($user->getUsername()); // prints NULL 
    die();
    return $this->loadUserByUsername($user->getUsername());
}

Upvotes: 0

Views: 98

Answers (1)

omarboussarsar
omarboussarsar

Reputation: 306

It seems that only the id attribute is public. However the username attribute is may be private. And for that, the serialization of the object user makes the username = null.

Upvotes: 1

Related Questions