0
votes

To authenticate manually a user I used the following code:

$user = new User($token, null, array("ROLE_USER"));
$token = new UsernamePasswordToken($user, null, 'secured_area', array("ROLE_USER"));
$this->get("security.context")->setToken($token);
$event = new InteractiveLoginEvent($request, $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);

The problem is that when I change page (also same controller) I lost the token/session.

Sometimes I get this: There is no user provider for user "Acme\MyBundle\Security\User".

How I should configure the secured area with pattern: ^/?

secured_area:
        pattern:    ^/

Thanks

1

1 Answers

0
votes

In FosUserBundle you can see an example of how to do Manual login correctly.