diff --git a/app/assets/javascripts/app/views/login.jst.eco b/app/assets/javascripts/app/views/login.jst.eco
index e4a345d1c..a8415287c 100644
--- a/app/assets/javascripts/app/views/login.jst.eco
+++ b/app/assets/javascripts/app/views/login.jst.eco
@@ -8,9 +8,9 @@
Sign in with
diff --git a/app/models/user.rb b/app/models/user.rb
index 2e32bc924..b1b328e9e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -13,10 +13,27 @@ class User < ApplicationModel
store :preferences
def self.authenticate( username, password )
+
+ # try to find user based on login
user = User.where( :login => username, :active => true ).first
- return nil if user.nil?
- return user if user.password == password
- return
+
+ # try second lookup with email
+ if !user
+ user = User.where( :email => username, :active => true ).first
+ end
+
+ # no user found
+ if !user
+ return nil
+ end
+
+ # auth ok
+ if user.password == password
+ return user
+ end
+
+ # auth failed
+ return false
end
def self.create_from_hash!(hash)