Chapters
47 Chapters
|
4:41:51
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial also works great for Symfony 6!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^3.3", // v3.3.0
"composer/package-versions-deprecated": "^1.11", // 1.11.99.4
"doctrine/annotations": "^1.0", // 1.13.2
"doctrine/doctrine-bundle": "^2.1", // 2.6.3
"doctrine/doctrine-migrations-bundle": "^3.0", // 3.1.1
"doctrine/orm": "^2.7", // 2.10.1
"knplabs/knp-markdown-bundle": "^1.8", // 1.9.0
"knplabs/knp-time-bundle": "^1.11", // v1.16.1
"pagerfanta/doctrine-orm-adapter": "^3.3", // v3.3.0
"pagerfanta/twig": "^3.3", // v3.3.0
"phpdocumentor/reflection-docblock": "^5.2", // 5.2.2
"scheb/2fa-bundle": "^5.12", // v5.12.1
"scheb/2fa-qr-code": "^5.12", // v5.12.1
"scheb/2fa-totp": "^5.12", // v5.12.1
"sensio/framework-extra-bundle": "^6.0", // v6.2.0
"stof/doctrine-extensions-bundle": "^1.4", // v1.6.0
"symfony/asset": "5.3.*", // v5.3.4
"symfony/console": "5.3.*", // v5.3.7
"symfony/dotenv": "5.3.*", // v5.3.8
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/form": "5.3.*", // v5.3.8
"symfony/framework-bundle": "5.3.*", // v5.3.8
"symfony/monolog-bundle": "^3.0", // v3.7.0
"symfony/property-access": "5.3.*", // v5.3.8
"symfony/property-info": "5.3.*", // v5.3.8
"symfony/rate-limiter": "5.3.*", // v5.3.4
"symfony/runtime": "5.3.*", // v5.3.4
"symfony/security-bundle": "5.3.*", // v5.3.8
"symfony/serializer": "5.3.*", // v5.3.8
"symfony/stopwatch": "5.3.*", // v5.3.4
"symfony/twig-bundle": "5.3.*", // v5.3.4
"symfony/ux-chartjs": "^1.3", // v1.3.0
"symfony/validator": "5.3.*", // v5.3.8
"symfony/webpack-encore-bundle": "^1.7", // v1.12.0
"symfony/yaml": "5.3.*", // v5.3.6
"symfonycasts/verify-email-bundle": "^1.5", // v1.5.0
"twig/extra-bundle": "^2.12|^3.0", // v3.3.3
"twig/string-extra": "^3.3", // v3.3.3
"twig/twig": "^2.12|^3.0" // v3.3.3
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3", // 3.4.0
"symfony/debug-bundle": "5.3.*", // v5.3.4
"symfony/maker-bundle": "^1.15", // v1.34.0
"symfony/var-dumper": "5.3.*", // v5.3.8
"symfony/web-profiler-bundle": "5.3.*", // v5.3.8
"zenstruck/foundry": "^1.1" // v1.13.3
}
}
15 Comments
This Login using binding service seems not working in Symfony 7, it says: that such service doesn't exist, and also. existing services related to form_login is not working, like what is the newer approach to do this work, to log the user in after registration ?
Hey @sujal_k,
In Symfony 7, programatic login is much easier! Check out the docs on this.
Hi Ryan !
Another great tutorial.
I probably have a stupid question : What's the point of using
FormLoginAuthenticator $formLoginAuthenticatorauthenticator when we could use our previousLoginFormAuthenticatorauthenticator ?This would be something like :
Thanks,
Marc.
Hey Marc,
The
UserAuthenticatorhas a different responsibility than our customLoginFormAuthenticator. Its job is to actually log in users into the system. As you can see, we're not making our users go through the login form after registration, so theUserAuthenticatorknows nothing about how to authenticate a request (validate credentials, etc)Cheers!
Hi there. What would you suggest for authentication with the WorkFlow component. The idea, in the registration form, user will provide some docs (id card...) and submit, the admin will then receive an notification and analyse the submitted item and decide to fully athenticate the user or not.
I'm planning just to add a new property to the User entity..like isValidated, boolean. Then, throught the WorkFlow component set that property to true when the admin accept the details sent throught the form. Is that correct !? Or what would you suggest?
Hey discipolat!
Sorry for the slow reply! That sounds very reasonable to me. If it's JUST this simple, I might not use the Workflow component, but that component is great, so I have no problems with it.
Does this help? Or did you also want to, somehow, authenticate the user the moment that the admin approves them?
Cheers!
Very helpful!
Yes you're wright indeed.
yes, just after the approvol authenticate the user.
The "Show Lines" feature seems to be broken in some code blocks on this page. For example try to load "... lines 1 - 11" in the first code block. Can you please fix this?
FYI codeblocks expanding back! Woohoo! Thank you for the reporting!
Hey @Guido
Sorry for that, We are working to solve this issue, soon this feature will come back!
Cheers and stay tuned!
At 4:32 I get the expected error "Cannot autowire ..." but it lacks the "Perhaps you should alias this class to..." part. Why is that?
Hey Matteo S.!
Hmm. Ok, here's how this works behind the scenes - it may help spot why you see the difference:
A) Symfony sees the type-hint for Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator that it can't autowire.
B) To give you the best error message, it then loops over every service in the container to see if any services have this class.
If a matching service (or services) ARE found, it'll give you that alias type-hint. If none are found, it won't. In this situation, I had the
security.authenticator.form_login.mainservice because I'm using theform_loginauthenticator under my "main" firewall. So my first guess would be that you maybe aren't usingform_loginunder your firewall? If you are, then yes, I would also expect you to see the exact same message as me :).Cheers!
Thank you! Indeed, turns out I'm not using form_login, but rather "custom_authenticator: App\Security\LoginFormAuthenticator" which I seem to remember was created by the Maker bundle.
Sweet! That explains it!
And yes, MakerBundle still generates a custom authenticator in all cases. I'm thinking we should change that by asking you a further question so we can determine if you really *need* a custom authenticator, or if we can just hook you up with form_login.
Cheers!
"Houston: no signs of life"
Start the conversation!