Q
Q
Qwyu_4iLofK2021-11-09 01:30:12
symfony
Qwyu_4iLofK, 2021-11-09 01:30:12

How to fix Authorization Error?

one.

Argument 4 passed to Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::__construct() must be of the type array, object given, called in /app/vendor/symfony/security-http/Authenticator/FormLoginAuthenticator.php on line 113

if the 4th parameter (getRoles) returns a collection of the Roles entity (the role I have is the entity)

roles and users are interconnected as many to many.

2. How to override the implemented method of the Roles entity if (user->getRoles returns a collection)

3. Access to /admin pages ... in my case, how would you forbid it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2021-11-09
@Maksclub

UserInterface implies that an array of strings (roles) will return
, either unbind your user from UserInterface (I did), or do as the interface requires

Q
Qwyu_4iLofK, 2021-11-09
@Qwyu_4iLofK

you need in the User entity:

public function getRoles():array
    {
        $ar=[];
        foreach ($this->role as $rol) {
            $ar[]=$rol->getCode();
        }
        return $ar;
    }

True or not, time will tell....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question