In this article I will show you a example of custom user provider in FOSUserBundle.
Let us imagine that we want to authenticate user only by email. In the latest version of this bundle you can authenticate user by username or by username || email combination. Code is pretty simple. You need only inject custom user provider.