You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Symfony\Bundle\SecurityBundle\Security\Security;
674
+
675
+
class ExampleController
676
+
{
677
+
public function __construct(private Security $security)
678
+
{
679
+
}
680
+
681
+
public function someMethod(): Response
682
+
{
683
+
$user = ... // Get the user to be authenticated
684
+
685
+
$this->security->login($user);
686
+
687
+
// Redirect the user to its account page for instance
688
+
// ...
689
+
}
690
+
}
691
+
692
+
The previous example only works if you have only one authenticator configured on the current firewall so if you have more than one authenticator, you need to specify which authenticator should be used.
693
+
If the firewall is not explicitly passed, the method will
694
+
be retrieved from the request. If the current request is not under any firewall an
695
+
`Symfony\\Component\\Security\\Core\\Exception\\LogicException` exception will be thrown.
696
+
697
+
You can also pass the authenticator on which the user will
698
+
be authenticated against. For built-in authenticators, you can pass an authenticator name like ``form_login``,
699
+
``http_basic``... For custom authenticators, you can pass the service id of the authenticator
0 commit comments