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 from scripts.handler.utility import Mongo_utility
# creating object for class in Utility # creating object for class in Utility
...@@ -10,8 +8,8 @@ class Mongobd: ...@@ -10,8 +8,8 @@ class Mongobd:
# method for inserting data into database # method for inserting data into database
@staticmethod @staticmethod
def insert(data, username, password): def insert(data, username, password):
# hashing the password # hashing the password by calling hashing method in utility
data["Password"] = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt()) data["Password"] = utility_object.hashing(password, '')
# connecting to database # connecting to database
register_details = utility_object.connection() register_details = utility_object.connection()
# find the data based on user_name in database # find the data based on user_name in database
...@@ -39,9 +37,8 @@ class Mongobd: ...@@ -39,9 +37,8 @@ class Mongobd:
# if user exists then finding the password using username as query # if user exists then finding the password using username as query
cursor = utility_object.finding(register_details, {"User Id": username}) cursor = utility_object.finding(register_details, {"User Id": username})
for key, value in cursor.next().items(): for key, value in cursor.next().items():
# validating user password with database password # validating user password with database password by calling hashing method in utility
# we use bcrypt.checkpw to compare hashed password if key == "Password" and utility_object.hashing(password, value):
if key == "Password" and bcrypt.checkpw(password.encode('utf8'), value):
flag = 1 flag = 1
break break
else: 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