Commit 185decfa authored by kranthi.kumar's avatar kranthi.kumar

Delete login_handler.py

parent b798c3ce
import bcrypt
from scripts.handler.utility import Mongo_utility
# creating object for class in Utility
utility_object = Mongo_utility()
class Mongobd:
# method for inserting data into database
@staticmethod
def insert(data, username):
# connecting to database
register_details = utility_object.connection()
# find the data based on user_name in database
require_data = utility_object.finding(register_details, {"User Id": username})
flag = 0
# checking if user exists or not
if len(list(require_data)) == 0:
flag = 1
# if user not exists then inserting data to database
if flag == 1:
utility_object.insert(register_details, data)
return flag
# method for validating user data with database
@staticmethod
def find_query(username, password):
# connecting to database
register_details = utility_object.connection()
cursor_list = list(utility_object.finding(register_details, {"User Id": username}))
flag = 0
# checking if user exists or not
if len(cursor_list) != 0:
# 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):
flag = 1
break
else:
flag = 2
return flag
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