php - Catchable Fatal Error: Argument 4 passed to UsernamePasswordToken::__construct() must be an array, null given -


i getting following error when logging in symfony application (with correct username , password):

contexterrorexception: catchable fatal error: argument 4 passed symfony\component\security\core\authentication\token\usernamepasswordtoken::__construct() must array, null given, called in d:\xampp\htdocs\essweb\vendor\symfony\symfony\src\symfony\component\security\core\authentication\provider\userauthenticationprovider.php on line 96 , defined in d:\xampp\htdocs\essweb\vendor\symfony\symfony\src\symfony\component\security\core\authentication\token\usernamepasswordtoken.php line 36

security.yml

firewalls:         admin_area:             pattern:    ^/             anonymous: ~             form_login:                 login_path:  /                 check_path:  /login_check                 default_target_path: /user                 failure_path: /                 #username_parameter: username                 #password_parameter: password                 remember_me: true              remember_me:                 key: "%secret%"                 lifetime: 31536000                 path: /                 domain: ~                 always_remember_me: true             logout:                 path:   /logout                 target: /   

updated:

login form:

<form class="form-signin form-group" action="{{ path('login_check') }}" method="post"> username: <input type="text" class="form-control" name="_username" placeholder="username" value="{{ last_username }}" required="required"> password: <input type="text" class="form-control" name="_password" placeholder="" value="{{ last_username }}" required="required"> <button class="btn btn-sm btn-primary btn-block" type="submit">sign in</button> 

basically, error message says is:

the 4th argument usernamepasswordtoken::__construct() should array, it's null. called in userauthenticationprovider @ line 96.

if take @ code, you'll see 4th argument usernamepasswordtoken::__construct() $roles. should array, it's getting null instead.

i'm guessing have written own user entity, , getroles() method of user entity returning null instead of array of roles. change method this:

/**  * returns roles granted user.  *   * @return role[] user roles  */ public function getroles() {     return array('role_user'); } 

of course, actual code may differ (you might want store user roles in database), long getroles() returns array of strings or role objects.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -