From 4c4cf2bc59c2f2aecedfd15a39f4010a3087c166 Mon Sep 17 00:00:00 2001 From: Farhaan Bukhsh Date: Mar 01 2017 08:35:30 +0000 Subject: Fix UnicodeEncode on entering non-ascii password The above changes encode the password to ``UTF_8`` to make the password compatible for ascii as well as non-ascii character. Signed-off-by: Farhaan Bukhsh --- diff --git a/pagure/lib/login.py b/pagure/lib/login.py index b821e20..937e332 100644 --- a/pagure/lib/login.py +++ b/pagure/lib/login.py @@ -51,7 +51,8 @@ def get_session_by_visitkey(session, sessionid): def generate_hashed_value(password): """ Generate hash value for password """ - return '$2$' + bcrypt.hashpw(to_unicode(password), bcrypt.gensalt()) + return '$2$' + bcrypt.hashpw(to_unicode(password).encode('UTF_8'), + bcrypt.gensalt()) def check_password(entered_password, user_password, seed=None): @@ -65,7 +66,8 @@ def check_password(entered_password, user_password, seed=None): _, version, user_password = user_password.split('$', 2) if version == '2': - password = bcrypt.hashpw(to_unicode(entered_password), user_password) + password = bcrypt.hashpw(to_unicode(entered_password).encode('UTF_8'), + user_password) elif version == '1': password = '%s%s' % (to_unicode(entered_password), seed)