Allow mail as login name. Implemented #428
This commit is contained in:
parent
991ffb2766
commit
a9970bec5b
|
@ -10,9 +10,15 @@ from flaschengeist import logger
|
|||
|
||||
def login_user(username, password):
|
||||
logger.info("login user {{ {} }}".format(username))
|
||||
try:
|
||||
user = User.query.filter(User.userid == username).one()
|
||||
except NoResultFound:
|
||||
mail = username.split("@")
|
||||
mail = len(mail) == 2 and len(mail[0]) > 0 and len(mail[1]) > 0
|
||||
|
||||
query = User.userid == username
|
||||
if mail:
|
||||
query |= User.mail == username
|
||||
user = User.query.filter(query).one_or_none()
|
||||
if not user:
|
||||
logger.debug("User not found in Database.")
|
||||
user = User(userid=username)
|
||||
db.session.add(user)
|
||||
if current_app.config["FG_AUTH_BACKEND"].login(user, password):
|
||||
|
|
Loading…
Reference in New Issue