Commit 4f6f6377 authored by arun.uday's avatar arun.uday

AssetManager-V1.0- Not yet reviewed

Added some changes to the documentation
parent 73dae1a2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
if __name__ == "__main__": if __name__ == "__main__":
from dotenv import load_dotenv from dotenv import load_dotenv
# getting the env variables
load_dotenv() load_dotenv()
import uvicorn import uvicorn
...@@ -15,6 +16,7 @@ ap = argparse.ArgumentParser() ...@@ -15,6 +16,7 @@ ap = argparse.ArgumentParser()
if __name__ == "__main__": if __name__ == "__main__":
try: try:
# creating the argument for the port
ap.add_argument( ap.add_argument(
"--port", "--port",
"-p", "-p",
...@@ -22,6 +24,7 @@ if __name__ == "__main__": ...@@ -22,6 +24,7 @@ if __name__ == "__main__":
default=Services.PORT, default=Services.PORT,
help="Port to start the application.", help="Port to start the application.",
) )
# creating the argument for the host
ap.add_argument( ap.add_argument(
"--bind", "--bind",
"-b", "-b",
...@@ -30,8 +33,9 @@ if __name__ == "__main__": ...@@ -30,8 +33,9 @@ if __name__ == "__main__":
help="IF to start the application.", help="IF to start the application.",
) )
arguments = vars(ap.parse_args()) arguments = vars(ap.parse_args())
# logging the info
logger.info(f"App Starting at {arguments['bind']}:{arguments['port']}") logger.info(f"App Starting at {arguments['bind']}:{arguments['port']}")
# starting the app
uvicorn.run("main:app", host=arguments["bind"], port=int(arguments["port"])) uvicorn.run("main:app", host=arguments["bind"], port=int(arguments["port"]))
except Exception as e: except Exception as e:
logger.exception(e) logger.exception(e)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Author: Arun Uday Author: Arun Uday
Email: arun.uday@knowledgelens.com Email: arun.uday@knowledgelens.com
Asset Manager Login For Normal User Asset Manager Login For Normal User Login
--------------------------------------------------------- ---------------------------------------------------------
...@@ -11,6 +11,7 @@ Asset Manager Login For Normal User ...@@ -11,6 +11,7 @@ Asset Manager Login For Normal User
if __name__ == "__main__": if __name__ == "__main__":
from dotenv import load_dotenv from dotenv import load_dotenv
# getting the env variables
load_dotenv() load_dotenv()
from fastapi import FastAPI from fastapi import FastAPI
...@@ -20,6 +21,7 @@ from fastapi.middleware.cors import CORSMiddleware ...@@ -20,6 +21,7 @@ from fastapi.middleware.cors import CORSMiddleware
from scripts.logging.logger import logger from scripts.logging.logger import logger
app = FastAPI() app = FastAPI()
# routing to the service
app.include_router(router) app.include_router(router)
# starting the application # starting the application
......
...@@ -28,21 +28,6 @@ class LoginHandlers: ...@@ -28,21 +28,6 @@ class LoginHandlers:
# un_padding the encrypted password # un_padding the encrypted password
return s[:-ord(s[len(s) - 1:])] return s[:-ord(s[len(s) - 1:])]
def new_user_login(self, login_data, password):
# check the domain of the email the user has entered
if login_data.username.split("@")[-1] == "knowledgelens.com":
# hash the password
hashed_password = self.pwd_context.hash(password)
# Enter the user as a guest user to the db
if self.mongo_user.insert_user(
self.mongo_queries.insert_user_query(
login_data,
Services.PROJECT_ID,
hashed_password,
self.time_dt)):
return True
return False
def password_decrypt(self, password): def password_decrypt(self, password):
try: try:
# encoding the Key # encoding the Key
...@@ -78,6 +63,21 @@ class LoginHandlers: ...@@ -78,6 +63,21 @@ class LoginHandlers:
except Exception as e: except Exception as e:
logger.exception(e) logger.exception(e)
def new_user_login(self, login_data, password):
# check the domain of the email the user has entered
if login_data.username.split("@")[-1] == "knowledgelens.com":
# hash the password
hashed_password = self.pwd_context.hash(password)
# Enter the user as a guest user to the db
if self.mongo_user.insert_user(
self.mongo_queries.insert_user_query(
login_data,
Services.PROJECT_ID,
hashed_password,
self.time_dt)):
return True
return False
def db_data_validation(self, login_data, password): def db_data_validation(self, login_data, password):
try: try:
# fetching the data based on the username # fetching the data based on the username
......
...@@ -530,3 +530,4 @@ SyntaxError: invalid syntax ...@@ -530,3 +530,4 @@ SyntaxError: invalid syntax
2023-03-20 10:50:34 - INFO - [MainThread:<module>(): 34] - App Starting at 0.0.0.0:8671 2023-03-20 10:50:34 - INFO - [MainThread:<module>(): 34] - App Starting at 0.0.0.0:8671
2023-03-20 10:55:39 - INFO - [MainThread:<module>(): 34] - App Starting at 0.0.0.0:8671 2023-03-20 10:55:39 - INFO - [MainThread:<module>(): 34] - App Starting at 0.0.0.0:8671
2023-03-20 11:07:35 - INFO - [MainThread:<module>(): 34] - App Starting at 0.0.0.0:8671 2023-03-20 11:07:35 - INFO - [MainThread:<module>(): 34] - App Starting at 0.0.0.0:8671
2023-03-20 12:15:30 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
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