W
W
wolfcruel972019-03-12 15:18:57
symfony
wolfcruel97, 2019-03-12 15:18:57

How to authorize a user by id?

How to authorize a user by id ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wolfcruel97, 2019-03-13
@wolfcruel97

Decision:

$user = $this->getDoctrine()->getRepository(User::class)->find(1);
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$tokenStorage = $this->get('security.token_storage');
$tokenStorage->setToken($token);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question