title: Spring Security using both username or email
body: <p>I'm using Spring Security in my Spring <code>MVC</code> app.</p>
  
  <p><code>JdbcUserDetailsManager</code> is initialized with the following query for authentication:</p>
  
  <pre><code>select username, password, enabled from user where username = ?
  </code></pre>
  
  <p>And authorities are being loaded here:</p>
  
  <pre><code>select u.username, a.authority from user u join authority a on u.userId = a.userId where username = ?
  </code></pre>
  
  <p>I would like to make it so that users can login with both username and email. Is there a way to modify these two queries to achieve that ? Or is there an even better solution ?</p>