login: Allow e-mail address instead of user name
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
782d4b4065
commit
083f3c3534
|
@ -57,13 +57,15 @@ def register_user(nickname, email, password):
|
||||||
|
|
||||||
def check_login_details(nickname, password):
|
def check_login_details(nickname, password):
|
||||||
mysql = FreifunkMySQL()
|
mysql = FreifunkMySQL()
|
||||||
|
user = mysql.findone("SELECT * FROM users WHERE nickname = %s LIMIT 1",(nickname,))
|
||||||
user = mysql.findone("SELECT * FROM users WHERE nickname = %s LIMIT 1",(nickname,))
|
userbymail = mysql.findone("SELECT * FROM users WHERE email = %s LIMIT 1",(nickname,))
|
||||||
mysql.close()
|
mysql.close()
|
||||||
|
|
||||||
if user and check_password_hash(user.get('password', ''), password):
|
if user and check_password_hash(user.get('password', ''), password):
|
||||||
return user
|
return user
|
||||||
else:
|
elif userbymail and check_password_hash(userbymail.get('password', ''), password):
|
||||||
return False
|
return userbymail
|
||||||
|
return False
|
||||||
|
|
||||||
def reset_user_password(mysql, email, token=None, password=None):
|
def reset_user_password(mysql, email, token=None, password=None):
|
||||||
userid = mysql.findone("SELECT id FROM users WHERE email = %s LIMIT 1",(email,),"id")
|
userid = mysql.findone("SELECT id FROM users WHERE email = %s LIMIT 1",(email,),"id")
|
||||||
|
|
Loading…
Reference in New Issue