Commit a7bc9ea3 authored by arun.uday's avatar arun.uday

AssetManager-V1.0- Not reviewed

Updated the code
parent 86779f3c
......@@ -8,9 +8,10 @@ from scripts.schemas.default_responses import DefaultFailureResponse, DefaultRes
class LoginHandlers:
def __init__(self):
self.obj_login_handler = NormalLogin()
self.login_type = ""
def normal_login(self, login_data, request):
self.login_type = "normal"
# decrypting the password from the UI
decrypted_password = self.obj_login_handler.password_decrypt(login_data.payload["password"])
......@@ -25,7 +26,7 @@ class LoginHandlers:
return JSONResponse(content=DefaultFailureResponse(error=response).dict(),
status_code=status.HTTP_400_BAD_REQUEST)
# checking for the account and password matching
response, data = self.obj_login_handler.db_password_matching(login_data.payload,
response, data = self.obj_login_handler.db_password_matching(self.login_type, login_data.payload,
decrypted_password)
# if the passwords doesn't match with the db data
if response is not None:
......
......@@ -66,7 +66,7 @@ class NormalLogin:
except Exception as e:
logger.exception(e)
def db_data_validation(self, username):
def db_data_validation(self, login_type, username):
try:
# fetching the data based on the username
self.db_user_data = MongoUser().fetch_user_details(username)
......@@ -76,7 +76,7 @@ class NormalLogin:
"data": {"username": username}}
# if the user is not registered through normal login
if self.db_user_data["login_type"] != "normal":
if self.db_user_data["login_type"] != login_type:
return False, {"message": ErrorMessages.ERROR_LOGIN_TYPE_INVALID,
"data": {"username": username, "Use Login": self.db_user_data["login_type"]}}
# Check the project id from the request body
......@@ -87,10 +87,10 @@ class NormalLogin:
except Exception as e:
logger.exception(e)
def db_password_matching(self, payload, password):
def db_password_matching(self, login_type, payload, password):
try:
# getting the response after checking for the user data in db
response, message = self.db_data_validation(payload["username"])
response, message = self.db_data_validation(login_type, payload["username"])
# if the response is false then an error message is send back
if response is not None:
return response, message
......
......@@ -877,3 +877,4 @@ TypeError: cannot unpack non-iterable NoneType object
2023-03-23 10:59:57 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-23 11:15:51 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-23 11:17:30 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-23 11:29:07 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
......@@ -17,7 +17,6 @@ async def login_default(
user_data: LoginRequest, request: MetaInfoSchema = Depends(auth)
):
try:
# mapper for login types
login_mapper = {
"normal": obj_login_handler.normal_login,
......
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