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