Commit 2f6951ee authored by kranthi.kumar's avatar kranthi.kumar

Update login_handler.py

parent 6a261d7b
import bcrypt
from scripts.handler.utility import Mongo_utility
# creating object for class in Utility
......@@ -10,8 +8,8 @@ class Mongobd:
# method for inserting data into database
@staticmethod
def insert(data, username, password):
# hashing the password
data["Password"] = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt())
# hashing the password by calling hashing method in utility
data["Password"] = utility_object.hashing(password, '')
# connecting to database
register_details = utility_object.connection()
# find the data based on user_name in database
......@@ -39,9 +37,8 @@ class Mongobd:
# if user exists then finding the password using username as query
cursor = utility_object.finding(register_details, {"User Id": username})
for key, value in cursor.next().items():
# validating user password with database password
# we use bcrypt.checkpw to compare hashed password
if key == "Password" and bcrypt.checkpw(password.encode('utf8'), value):
# validating user password with database password by calling hashing method in utility
if key == "Password" and utility_object.hashing(password, value):
flag = 1
break
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment