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
+
public function someMethod(): Response
681
+
{
682
+
$user = ... // Get the user to be authenticated
683
+
684
+
$this->security->login($user);
685
+
686
+
// Redirect the user to its account page for instance
687
+
// ...
688
+
}
689
+
}
690
+
691
+
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.
692
+
If the firewall is not explicitly passed, the method will
693
+
be retrieved from the request. If the current request is not under any firewall an
694
+
`Symfony\\Component\\Security\\Core\\Exception\\LogicException` exception will be thrown.
695
+
696
+
You can also pass the authenticator on which the user will
697
+
be authenticated against. For built-in authenticators, you can pass an authenticator name like ``form_login``,
698
+
``http_basic``... For custom authenticators, you can pass the service id of the authenticator
0 commit comments