diff --git a/kallithea/controllers/login.py b/kallithea/controllers/login.py --- a/kallithea/controllers/login.py +++ b/kallithea/controllers/login.py @@ -91,7 +91,7 @@ class LoginController(BaseController): c.form_result = login_form.to_python(dict(request.POST)) # form checks for username/password, now we're authenticated username = c.form_result['username'] - user = User.get_by_username(username, case_insensitive=True) + user = User.get_by_username_or_email(username, case_insensitive=True) except formencode.Invalid as errors: defaults = errors.value # remove password from filling in form again diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py --- a/kallithea/model/validators.py +++ b/kallithea/model/validators.py @@ -313,7 +313,7 @@ def ValidAuth(): # authenticate returns unused dict but has called # plugin._authenticate which has create_or_update'ed the username user in db if auth_modules.authenticate(username, password) is None: - user = User.get_by_username(username) + user = User.get_by_username_or_email(username) if user and not user.active: log.warning('user %s is disabled', username) msg = M(self, 'invalid_auth', state) diff --git a/kallithea/tests/functional/test_login.py b/kallithea/tests/functional/test_login.py --- a/kallithea/tests/functional/test_login.py +++ b/kallithea/tests/functional/test_login.py @@ -50,6 +50,17 @@ class TestLoginController(TestController response = response.follow() response.mustcontain('/%s' % HG_REPO) + def test_login_regular_email_ok(self): + response = self.app.post(url(controller='login', action='index'), + {'username': TEST_USER_REGULAR_EMAIL, + 'password': TEST_USER_REGULAR_PASS}) + + self.assertEqual(response.status, '302 Found') + self.assert_authenticated_user(response, TEST_USER_REGULAR_LOGIN) + + response = response.follow() + response.mustcontain('/%s' % HG_REPO) + def test_login_ok_came_from(self): test_came_from = '/_admin/users' response = self.app.post(url(controller='login', action='index',