I use symfony 2.8, I am new to symfony, I have implemented login and registration, registration works fine, but when I log in, it shows this error
Type error: Argument 4 passed to Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::__construct() must be of the type array, string given, called in C:\xampp\htdocs\blog\vendor\symfony\symfony\src\Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider.php on line 96
Now I'm a little confused in the implementation of ROLES, I have a user table in the database,
TABLE OF USERS
id Primary int(11) name varchar(255) email Index varchar(255) password varchar(64) roles varchar(255) created_at datetime
Custom
public function setRoles($roles) { $this->roles = $roles; } public function getRoles() { return $this->roles; }
security.yml firewall section
firewalls:
If I change the getRoles function to return an array like this
public function getRoles() { return array('ROLE_USER'); }
In this case, an error is displayed on the registration page.
The value of type "array" cannot be converted to a valid array key.
Aamir source share