FOS' UserManager class implements UserProviderInterface, which means Security component uses it to fetch accounts (e.g. when loading an account to check its password). The method of interest here is loadUserByUsername(). Assuming your usernames don't allow "@" signs, you'll want to modify FOS' basic implementation to use findUserByUsernameOrEmail() instead of findUserByUsername(). But rather than modifying the class in FOS directly, you should make your own class that extends either the Document or Entity UserManager classes (which in turn extend the basic Model\UserManager class that has the method we wish to override).
I'm sure you're familiar with the UserManager classes. Depending on whether you configure FOS UserBundle to use ODM or ORM, the fos_user.user_manager service will utilize the appropriate class based on a DI parameter. UserBundle currently doesn't expose the UserManager's class as a configuration parameter, so your best bet is to set it explicitly in your application config. I may be a bit rusty with the latest Symfony2 HEAD, but this should still be possible from your application config: parameters: fos_user.user_manager.class: YourNamespace\UserManager Your custom class should extend either the Document\UserManager or Entity\UserManager class from FOS. Keep in mind that you're now hard-coded to using a Document or Entity UserManager by your explicit extension, since you're not allowing FOS to conditionally decide which UserManager service definition to load itself based on its configuration. If you feel like submitting a pull request, exposing the fos_user.user_manager.class and fos_user.group_manager.class parameters in the bundle configuration would be a worthwhile contribution. On Tue, Apr 19, 2011 at 8:24 AM, Conrad <conrad.barthel...@googlemail.com>wrote: > Hi all, > how can I modify the login process to allow the user to authenticate both > with email address or username for the FOS UserBundle? > I already looked through the default configuration but didnt find it.. > > Cheers, Conrad > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- jeremy mikola -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en