Added support for login either with username or email address

Hi Peter, 
I made some simple changes to add support for logging in both with username or email address. Users can either type username and password, or their email address and password to log in successfully. Please have a look.