Allowing users to authenticate with email

Default usage is preserved, but if id_type parameter is passed to authenticate() it can be decided whether username or email is used for authentication.