-
Notifications
You must be signed in to change notification settings - Fork 111
Two-factor authentication form is not shown after login #289
Comments
If the 2fa is not shown, what's shown instead? I've seen that your entire application is protected with What happens when you navigate to |
All the pages are accessible(based on dynamic roles I have) except My User entity role getter updated with custom roles I have in my permissions table, which gets assigned based on user group to different users. Because in user table by default all user will have ROLE_USER while admin will have ROLE_ADMIN, others will be from permissions and group relationship as shown in
I also have event listener which gets called on My custom event subscriber class which adds all the permissions(ROLES) to admin/superadmin users.
|
I'd suggest you change your code in
to:
This will make sure:
|
Alternatively, instead of using |
Wow, super fast. Thanks for the replies. It now redirects to
|
Well, that is the template you have configured in scheb_two_factor:
security_tokens:
template: security/2fa_form.html.twig # Template used to render the authentication form Make sure the file is there ;) |
Ohh, I forgot to add template thought using default you provided. Add now (had to remove logout and cancel link as I have different path). So now it redirects to form but no email process. |
I have
|
This method should be called to send the email. https://github.com/scheb/two-factor-bundle/blob/master/Mailer/AuthCodeMailer.php#L33 Once that method is called, it's the responsibility of your email setup to send-out the mail. |
Yes, that method gets called. Thank you very much for your help. I will follow documentation for creating Custom Mailer from there I will need to send email using Mailer Interface. |
Replacing Updated event you suggested from However, instance of Hence, my code to update roles for user fails, due to Replacing Updated subscriber class:
|
Please use And please note that Btw., the way you're injecting these extra roles, I don't think this is the best way to do it, messing around with the security token. Overwriting the security token is a bit hacky, I believe the security token should only be modified by the security system. The more safe way to do this would probably be to write your own user provider, which adds these extra roles to the user when it's loaded from the database. |
Thanks for the help and suggestions. Instead of replacing security token, updated
|
Sounds good to me 👍 |
@hardiksinh Can we close this? |
Yes |
Bundle version: 4.16.0 and also tried downgrading to 3.29.0
Symfony version: 4.3.3
Description
Followed Troubleshooting guide and reached at step 5 which returns email as one value in array.
config\packages\security.yaml
config\routes.yaml
config\packages\scheb_two_factor.yaml
src\Entity\User.php
Additional Context
Using FOSUserBundle for authentication.
Using Doctrine2 behavioral extension for soft-delete (just for the info, because another extension, audit logger extension, I once used had event subscriber priority related issue, could that be the case?).
The text was updated successfully, but these errors were encountered: