On 05/15/2015 07:06 PM, Andrew Shadura wrote:
# HG changeset patch
# User Andrew Shadura <[email protected]>
# Date 1431709586 -7200
# Fri May 15 19:06:26 2015 +0200
# Node ID 1a7787acd1276557128ac6f8cd274b39c86ebbae
# Parent 95bffe63997d40bfab5ae6b8d1a54859d6275471
auth: let users log in using their email address
Nice and simple - thanks!
This will however crash if the user specifies an invalid email address.
This feature also seems a bit half-baked when it only is for web login.
Hg/git login should work the same way.
FWIW: The only other place where users have to care about their (and
others) "login" is in @mention. It would be nice to be able to specify
email addresses there too. @[email protected] should work in the
scanner (regexp) and auto completer. Some users would perhaps prefer to
avoid exposing their email address so it should perhaps be configurable
somehow ... but I'm pretty sure we already expose email addresses in
other places so such a "privacy" option would be a separate feature.
/Mads
diff --git a/kallithea/controllers/login.py b/kallithea/controllers/login.py
--- a/kallithea/controllers/login.py
+++ b/kallithea/controllers/login.py
@@ -121,9 +121,15 @@ class LoginController(BaseController):
session.invalidate()
c.form_result = login_form.to_python(dict(request.POST))
# form checks for username/password, now we're authenticated
+
+ username = c.form_result['username']
+ if '@' in username:
+ username = User.get_by_email(username).username
+ remember = c.form_result['remember']
+
headers = self._store_user_in_session(
- username=c.form_result['username'],
- remember=c.form_result['remember'])
+ username=username,
+ remember=remember)
raise HTTPFound(location=c.came_from, headers=headers)
except formencode.Invalid, errors:
defaults = errors.value
diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py
--- a/kallithea/model/validators.py
+++ b/kallithea/model/validators.py
@@ -316,6 +316,9 @@ def ValidAuth():
password = value['password']
username = value['username']
+ if '@' in username:
+ username = User.get_by_email(username).username
+
if not auth_modules.authenticate(username, password):
user = User.get_by_username(username)
if user and not user.active:
_______________________________________________
kallithea-general mailing list
[email protected]
http://lists.sfconservancy.org/mailman/listinfo/kallithea-general
_______________________________________________
kallithea-general mailing list
[email protected]
http://lists.sfconservancy.org/mailman/listinfo/kallithea-general