Commit 03f4f9a7 authored by arun.uday's avatar arun.uday

AssetManager-V1.0- Not Reviewed

Created download api for the download button, changed the login api , added API's for forgot password and user data filter, changed response data for UI display.
parent 53073373
......@@ -13,4 +13,12 @@ BASE_PATH=scripts/
SUB_PATH=log/
ENCODING_TYPE=utf-8
KEY_ENCRYPTION=kliLensKLiLensKL
\ No newline at end of file
KEY_ENCRYPTION=kliLensKLiLensKL
SECRET_KEY=09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7
EMAIL_SENDER=arun.send.email@gmail.com
EMAIL_SMTP=smtp.gmail.com
EMAIL_PORT=465
EMAIL_PASSWORD=gpphuiweedqukchf
HTML_LINK=scripts/utils/link_email.html
RESET_ENDPOINT=http://localhost:8671/v1/login/reset?token
\ No newline at end of file
......@@ -16,6 +16,12 @@ class _Services(BaseSettings):
CORS_ALLOW_HEADERS: list[str] = ["*"]
LOG_LEVEL: Literal["INFO", "DEBUG", "ERROR", "QTRACE"] = "INFO"
ENABLE_FILE_LOGGING: bool = False
EMAIL_SENDER: str
EMAIL_SMTP: str
EMAIL_PORT: int
EMAIL_PASSWORD: str
HTML_LINK: str
RESET_ENDPOINT: str
class _Databases(BaseSettings):
......@@ -36,10 +42,11 @@ class _PathConf:
class _Secrets(BaseSettings):
ACCESS_TOKEN_EXPIRE_MINUTES = 30
TOKEN_EXPIRE_TIME = 5
leeway_in_minutes: int = 10
KEY_ENCRYPTION: str
issuer: str = "iotManager"
SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"
SECRET_KEY: str
ALGORITHM = "HS256"
......
......@@ -10,10 +10,15 @@ class ApiEndPoints:
delete: str = "/delete"
header: str = "/header"
download: str = "/download"
search: str = "/search"
forgot: str = "/forgot"
reset: str = "/reset"
# login-management
asset_manager_login: str = "/login"
asset_manager_submit: str = asset_manager_login + submit
asset_manager_forgot: str = asset_manager_login + forgot
asset_manager_reset: str = asset_manager_login + reset
# user-management
asset_manager_user_management: str = "/users"
......@@ -21,6 +26,7 @@ class ApiEndPoints:
asset_manager_user_view: str = asset_manager_user_management + view
asset_manager_user_update: str = asset_manager_user_management + update
asset_manager_user_delete: str = asset_manager_user_management + delete
asset_manager_user_search: str = asset_manager_user_management + search
# dashboard-management
asset_manager_dashboard: str = "/dashboard"
......
from fastapi.responses import JSONResponse
from fastapi import status
from scripts.logging.logger import logger
from scripts.schemas.default_responses import DefaultResponse
from scripts.utils.response_utils import ResponseData
obj_download_util = ResponseData()
class DashboardManagement:
def __init__(self):
self.download_files = {
"SCN101-Manual (Local Config with IoTSetupUI)":
"https://ilens.io/DownloadFiles/SCN_Device_Configuration_Page_Updates_4_7.pdf",
"SCN101 Firmware 4.7 Updates":
"https://ilens.io/DownloadFiles/SCN101Manual.pdf",
"IoTSetupUI":
"https://ilens.io/DownloadFiles/IoTsetupUI-V1.6.zip",
"CP2102 SCN Windows USB Driver":
"https://ilens.io/DownloadFiles/CP2102_Windows.zip",
"SCNFirmwareBurner":
"https://ilens.io/DownloadFiles/flash_download_tool_v3.8.5.zip",
"SCN101A Firmware - V2.7 (Board: 1.4, 1.6 and 4MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_Firmware_V2_7_B1_6.bin",
"SCN101A Firmware - V2.8 (Board: 1.4, 1.6 and 4MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_Firmware_V2_8_B1_6.bin",
"SCN101A4G (SCN Relay, 4G, SCN201 and SCN101L) Firmware - V4.5 (16MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_R_A4G_SCN201_Firmware_V4_5.bin",
"SCN101A4G (SCN Relay, 4G, SCN201 and SCN101L) Firmware - V4.6 (16MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_R_A4G_SCN201_Firmware_V4_6.bin",
"SCN101A4G (SCN Relay, 4G, SCN201 and SCN101L) Firmware - V4.7 (16MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_R_A4G_SCN201_Firmware_V4_7.bin",
"P10_LED_Driver_V2.1 (Board 1.1)":
"https://ilens.io/DownloadFiles/P10_LED_Driver_V2.1.bin",
"SCN-LED Reset Firmware (Board 1.1)":
"https://ilens.io/DownloadFiles/SCN-LED_Reset.bin",
"SCN Reset Firmware (Partition: 4MB)":
"https://ilens.io/DownloadFiles/SCN_Reset_4MB_Part.bin",
"SCN Reset Firmware (Partition: 16MB)":
"https://ilens.io/DownloadFiles/SCN_Reset_16MB_Part.bin"
}
self.download_files = obj_download_util.download_file_data()
def download_header(self):
data = {
"actions": [
{
"class": "fa-download",
"action": "download",
"tooltip": "Download"
}
],
"column_defs": []
}
print(data["column_defs"])
column_values = {{"header_name": key, "field": key, "key": "file_name"} for key in self.download_files}
print(column_values)
data["column_defs"].append(column_values)
print(data)
return JSONResponse(
content=DefaultResponse(status="success", message="Fetched Successfully",
data=data).dict(),
status_code=status.HTTP_200_OK)
try:
data = {
"actions": [
{
"class": "fa-download",
"action": "download",
"tooltip": "Download"
}
],
"columnDefs": [
{
"headerName": "File Name",
"field": "file_name",
"key": "file_name"
}],
@staticmethod
def download_details():
return JSONResponse(
content=DefaultResponse(status="success", message="Fetched Successfully",
data=download_files).dict(),
status_code=status.HTTP_200_OK)
}
column_urls = [{"file_name": key, "file_url": value} for key, value in self.download_files.items()]
data["rowData"] = column_urls
return JSONResponse(
content=DefaultResponse(status="success", message="Fetched Successfully",
data=data).dict(),
status_code=status.HTTP_200_OK)
except Exception as e:
logger.exception(e)
from fastapi import Response
import smtplib
import ssl
from datetime import timedelta, datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from scripts.core.handlers.normal_login import NormalLogin
from fastapi.responses import JSONResponse
from fastapi import status
from fastapi.responses import JSONResponse
from scripts.config import Services, Secrets
from scripts.core.handlers.normal_login import NormalLogin
from scripts.database.mongo.mongo_db import MongoUser
from scripts.errors import ErrorMessages
from scripts.logging.logger import logger
from scripts.schemas.default_responses import DefaultFailureResponse, DefaultResponse
from scripts.utils.security.jwt_util import JWT
from scripts.utils.security.password_util import EncryptDecryptPassword
obj_mongo_user = MongoUser()
jwt = JWT()
class LoginHandlers:
def __init__(self):
......@@ -15,10 +27,11 @@ class LoginHandlers:
self.login_type = ""
def normal_login(self, user_data, request):
self.login_type = "normal"
self.login_type = "general_login"
# decrypting the password from the UI
decrypted_password = self.pass_decrypt.password_decrypt(user_data.password)
# validating the received inputs empty or not
# password decrypted form - token "password"
responses = self.obj_login_handler.user_data_validation(
user_data.email,
decrypted_password.split("\"")[1])
......@@ -58,3 +71,49 @@ class LoginHandlers:
# v2
def microsoft_login(self, request):
pass
@staticmethod
def forgot_password_handler(email):
try:
# Check if user exists in database
# If user exists, send forgot password email with JWT token
# This should include email and expire time
# Send email using MIME
db_user_data = obj_mongo_user.fetch_one_user_details(email)
# if the user is not available
if not db_user_data:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_EMAIL_ID_DOESNT_EXIST).dict(),
status_code=status.HTTP_200_OK)
mail = MIMEMultipart()
mail['From'] = Services.EMAIL_SENDER
mail['To'] = email
mail['Subject'] = "Link TO Reset Password"
to_encode = {"email": email}
expire = datetime.utcnow() + timedelta(minutes=Secrets.TOKEN_EXPIRE_TIME)
to_encode.update({"exp": expire})
jwt_token = jwt.encode(to_encode)
html = ''
# Load the HTML file
try:
with open(Services.HTML_LINK, "r") as f:
html = f.read()
html = html.replace("{{ message }}", "Please click the link to reset your password:").replace(
"{{ link }}", Services.RESET_ENDPOINT + "=" + str(jwt_token))
except Exception as e:
logger.exception(e)
html_body = MIMEText(html, "html")
mail.attach(html_body)
context = ssl.create_default_context()
with smtplib.SMTP_SSL(Services.EMAIL_SMTP, Services.EMAIL_PORT, context=context) as smtp:
smtp.login(Services.EMAIL_SENDER, Services.EMAIL_PASSWORD)
# sending the mail
smtp.sendmail(Services.EMAIL_SENDER, email, mail.as_string())
return JSONResponse(
content=DefaultResponse(status="success", message="Email Send Successfully",
data={"username": email}).dict(),
status_code=status.HTTP_200_OK)
except Exception as e:
logger.exception(e)
......@@ -40,7 +40,6 @@ class NormalLogin:
# if the user is not available
if not self.db_user_data:
return False, ErrorMessages.ERROR_UNAUTHORIZED_USER_LOGIN
# if the user is not registered through normal login
if self.db_user_data["login_type"] != login_type:
return False, ErrorMessages.ERROR_LOGIN_TYPE_INVALID
......
......@@ -6,10 +6,12 @@ from scripts.logging.logger import logger
from fastapi.responses import JSONResponse
from fastapi import status
from scripts.schemas.default_responses import DefaultResponse, DefaultFailureResponse
from scripts.utils.response_utils import ResponseData
from scripts.utils.security.password_util import EncryptDecryptPassword
from scripts.utils.validations_util import UserDataValidations
obj_mongo_user = MongoUser()
obj_response_data = ResponseData()
class UserManagement:
......@@ -19,15 +21,20 @@ class UserManagement:
# for normal registration using email and password
def normal_register(self, user_data):
try:
response, message = UserDataValidations.register_data_validation(user_data, 'normal', self.method)
response, message = UserDataValidations.register_data_validation(user_data, 'general', self.method)
if not response:
return message
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=message["message"]).dict(),
status_code=status.HTTP_200_OK)
# fetching the data based on the username
db_user_data = obj_mongo_user.fetch_one_user_details(user_data.email)
# if the user is not available
if db_user_data:
return {"message": ErrorMessages.ERROR_EMAIL_EXIST,
"data": {"username": user_data.email}}
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_EMAIL_EXIST).dict(),
status_code=status.HTTP_200_OK)
created_at = datetime.datetime.now()
updated_at = datetime.datetime.now()
reg_time = {"created_at": created_at, "updated_at": updated_at}
......@@ -35,10 +42,14 @@ class UserManagement:
if key == "password" else value) for key, value in user_data}
user_data_reg = user_data_dict | reg_time
if not obj_mongo_user.insert_new_user(user_data_reg):
return {"message": ErrorMessages.ERROR_STORING_DATA,
"data": {"username": user_data_dict}}
return {"message": "New user registered",
"data": {"username": user_data_dict["email"]}}
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_STORING_DATA).dict(),
status_code=status.HTTP_200_OK)
return JSONResponse(
content=DefaultResponse(status="success", message="Inserted Successfully",
data={"username": user_data_dict["email"]}).dict(),
status_code=status.HTTP_200_OK)
except Exception as e:
logger.exception(e)
......@@ -133,6 +144,19 @@ class UserManagement:
list_user_data = []
for users in cursor_data:
list_user_data.append(users)
data_response = obj_response_data.user_view()
print(data_response.update({"rowData": list_user_data}))
return JSONResponse(
content=DefaultResponse(status="success", message="Fetched Successfully",
data=data_response).dict(),
status_code=status.HTTP_200_OK)
except Exception as e:
logger.exception(e)
@staticmethod
def user_filter_data(body_data):
try:
return JSONResponse(
content=DefaultResponse(status="success", message="Fetched Successfully",
data=list_user_data).dict(),
......
......@@ -2621,3 +2621,259 @@ Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 51, in <setcomp>
column_values = {{"header_name": key, "field": key, "key": "file_name"} for key in self.download_files}
TypeError: unhashable type: 'dict'
2023-03-28 09:46:48 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 09:47:01 - ERROR - [MainThread:dashboard_download(): 177] - unhashable type: 'dict'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 170, in dashboard_download
response = obj_dashboard_handler.download_header()
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 51, in download_header
column_values = {{"header_name": key, "field": key, "key": "file_name"} for key in self.download_files}
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 51, in <setcomp>
column_values = {{"header_name": key, "field": key, "key": "file_name"} for key in self.download_files}
TypeError: unhashable type: 'dict'
2023-03-28 09:47:45 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 09:50:39 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 09:50:43 - ERROR - [MainThread:dashboard_download(): 177] - too many values to unpack (expected 2)
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 170, in dashboard_download
response = obj_dashboard_handler.download_header()
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 55, in download_header
column_urls = [{"file_name": key, "file_url": value} for key, value in self.download_files]
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 55, in <listcomp>
column_urls = [{"file_name": key, "file_url": value} for key, value in self.download_files]
ValueError: too many values to unpack (expected 2)
2023-03-28 09:51:39 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 09:51:47 - ERROR - [MainThread:dashboard_download(): 177] - too many values to unpack (expected 2)
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 170, in dashboard_download
response = obj_dashboard_handler.download_header()
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 55, in download_header
column_urls = [{"file_name": key, "file_url": value} for key, value in self.download_files]
File "E:\Git\meta-services\scripts\core\handlers\dashboard_handler.py", line 55, in <listcomp>
column_urls = [{"file_name": key, "file_url": value} for key, value in self.download_files]
ValueError: too many values to unpack (expected 2)
2023-03-28 09:52:12 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 09:53:10 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 09:59:52 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:08:05 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:11:17 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:16:38 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:25:01 - ERROR - [MainThread:user_register(): 82] - 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 61, in user_register
response = AuthorizeAccess().admin_authorize(request)
File "E:\Git\meta-services\scripts\utils\security\authorize_access.py", line 10, in admin_authorize
if user_data["user_role"] != "super admin":
TypeError: 'NoneType' object is not subscriptable
2023-03-28 10:26:23 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:26:30 - ERROR - [MainThread:user_register(): 82] - 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 61, in user_register
response = AuthorizeAccess().admin_authorize(request)
File "E:\Git\meta-services\scripts\utils\security\authorize_access.py", line 11, in admin_authorize
if user_data["user_role"] != "super admin":
TypeError: 'NoneType' object is not subscriptable
2023-03-28 10:27:56 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:28:21 - ERROR - [MainThread:user_register(): 82] - 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 61, in user_register
response = AuthorizeAccess().admin_authorize(request)
File "E:\Git\meta-services\scripts\utils\security\authorize_access.py", line 12, in admin_authorize
if user_data["user_role"] != "super admin":
TypeError: 'NoneType' object is not subscriptable
2023-03-28 10:29:02 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:30:00 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:30:53 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:37:50 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 10:41:50 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:52:02 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:53:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:53:32 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:54:28 - ERROR - [MainThread:user_search_filter(): 209] - 'Request' object has no attribute 'payload'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 202, in user_search_filter
response = obj_user_handler.user_filter_data(payload_data)
File "E:\Git\meta-services\scripts\core\handlers\user_management_handler.py", line 149, in user_filter_data
print(request.payload)
AttributeError: 'Request' object has no attribute 'payload'
2023-03-28 11:54:55 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:54:58 - ERROR - [MainThread:user_search_filter(): 209] - 'Request' object has no attribute 'cookie'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 202, in user_search_filter
response = obj_user_handler.user_filter_data(payload_data)
File "E:\Git\meta-services\scripts\core\handlers\user_management_handler.py", line 149, in user_filter_data
print(request.cookie)
AttributeError: 'Request' object has no attribute 'cookie'
2023-03-28 11:56:26 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:56:38 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:57:49 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:57:50 - ERROR - [MainThread:<module>(): 41] - 'await' outside async function (user_management_handler.py, line 149)
Traceback (most recent call last):
File "E:\Git\meta-services\app.py", line 39, in <module>
uvicorn.run("main:app", host=arguments["bind"], port=int(arguments["port"]))
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\main.py", line 568, in run
server.run()
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\server.py", line 59, in run
return asyncio.run(self.serve(sockets=sockets))
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
return future.result()
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\server.py", line 66, in serve
config.load()
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\config.py", line 471, in load
self.loaded_app = import_from_string(self.app)
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "E:\Git\meta-services\main.py", line 17, in <module>
from scripts.services import router
File "E:\Git\meta-services\scripts\services\__init__.py", line 2, in <module>
from scripts.services import v1
File "E:\Git\meta-services\scripts\services\v1\__init__.py", line 3, in <module>
from scripts.services.v1 import iot_manager_services
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 7, in <module>
from scripts.core.handlers.user_management_handler import UserManagement
File "E:\Git\meta-services\scripts\core\handlers\user_management_handler.py", line 149
print(await request.json())
^
SyntaxError: 'await' outside async function
2023-03-28 11:58:28 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:59:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 11:59:20 - ERROR - [MainThread:user_search_filter(): 210] - Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 202, in user_search_filter
print(await payload_data.json())
File "E:\Git\meta-services\venv\lib\site-packages\starlette\requests.py", line 244, in json
self._json = json.loads(body)
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2023-03-28 12:00:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:01:30 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:02:24 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:06:01 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:09:15 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:09:35 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:09:59 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:10:31 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:10:46 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:18:50 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:20:39 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:21:03 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:27:30 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:34:49 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:35:46 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:36:16 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:37:27 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 12:38:19 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:12:02 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:13:25 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:13:41 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:20:40 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:26:26 - ERROR - [MainThread:user_filter_data(): 161] - name 'list_user_data' is not defined
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\user_management_handler.py", line 158, in user_filter_data
data=list_user_data).dict(),
NameError: name 'list_user_data' is not defined
2023-03-28 14:29:38 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:33:35 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 14:33:55 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:05:16 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:16:42 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:16:43 - ERROR - [MainThread:<module>(): 41] - Invalid args for response field! Hint: check that <class 'scripts.schemas.project_schema.EmailValidation'> is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/
Traceback (most recent call last):
File "E:\Git\meta-services\app.py", line 39, in <module>
uvicorn.run("main:app", host=arguments["bind"], port=int(arguments["port"]))
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\main.py", line 568, in run
server.run()
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\server.py", line 59, in run
return asyncio.run(self.serve(sockets=sockets))
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
return future.result()
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\server.py", line 66, in serve
config.load()
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\config.py", line 471, in load
self.loaded_app = import_from_string(self.app)
File "E:\Git\meta-services\venv\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "C:\Users\arun.uday\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "E:\Git\meta-services\main.py", line 17, in <module>
from scripts.services import router
File "E:\Git\meta-services\scripts\services\__init__.py", line 2, in <module>
from scripts.services import v1
File "E:\Git\meta-services\scripts\services\v1\__init__.py", line 3, in <module>
from scripts.services.v1 import iot_manager_services
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 56, in <module>
async def forgot_password(
File "E:\Git\meta-services\venv\lib\site-packages\fastapi\routing.py", line 661, in decorator
self.add_api_route(
File "E:\Git\meta-services\venv\lib\site-packages\fastapi\routing.py", line 600, in add_api_route
route = route_class(
File "E:\Git\meta-services\venv\lib\site-packages\fastapi\routing.py", line 446, in __init__
self.dependant = get_dependant(path=self.path_format, call=self.endpoint)
File "E:\Git\meta-services\venv\lib\site-packages\fastapi\dependencies\utils.py", line 303, in get_dependant
type_annotation, depends, param_field = analyze_param(
File "E:\Git\meta-services\venv\lib\site-packages\fastapi\dependencies\utils.py", line 461, in analyze_param
field = create_response_field(
File "E:\Git\meta-services\venv\lib\site-packages\fastapi\utils.py", line 87, in create_response_field
raise fastapi.exceptions.FastAPIError(
fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that <class 'scripts.schemas.project_schema.EmailValidation'> is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/
2023-03-28 18:18:23 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:18:51 - ERROR - [MainThread:encode(): 18] - Exception while encoding JWT: Expecting a mapping object, as JWT only supports JSON objects as payloads.
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 16, in encode
return jwt.encode(payload, self.key, algorithm=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 51, in encode
raise TypeError(
TypeError: Expecting a mapping object, as JWT only supports JSON objects as payloads.
2023-03-28 18:18:51 - ERROR - [MainThread:forgot_password_handler(): 118] - Expecting a mapping object, as JWT only supports JSON objects as payloads.
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 95, in forgot_password_handler
jwt_token = jwt.encode(email)
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 16, in encode
return jwt.encode(payload, self.key, algorithm=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 51, in encode
raise TypeError(
TypeError: Expecting a mapping object, as JWT only supports JSON objects as payloads.
2023-03-28 18:20:10 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:27:50 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:30:43 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:31:17 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:37:38 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:39:12 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:39:20 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:40:07 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 18:42:02 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:10:55 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:12:56 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:13:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:19:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:20:08 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:20:52 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:21:40 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:21:50 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 19:59:41 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 20:00:18 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 20:00:35 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-28 20:03:00 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
......@@ -23,3 +23,7 @@ class UserUpdate(BaseModel):
email: Optional[str] = None
phone_number: Optional[str] = None
user_role: Optional[str] = None
class EmailValidation(BaseModel):
email: str
......@@ -8,7 +8,7 @@ from scripts.core.handlers.user_management_handler import UserManagement
from scripts.errors import ErrorMessages
from scripts.logging.logger import logger
from scripts.schemas.default_responses import DefaultFailureResponse
from scripts.schemas.project_schema import LoginRequest, RegistrationData, UserUpdate
from scripts.schemas.project_schema import LoginRequest, RegistrationData, UserUpdate, EmailValidation
from scripts.utils.security.authorize_access import AuthorizeAccess
from scripts.utils.security.decorators import MetaInfoSchema, auth
......@@ -30,7 +30,7 @@ async def login_default(
try:
# mapper for login types
login_mapper = {
"normal": obj_login_handler.normal_login,
"general_login": obj_login_handler.normal_login,
"google": obj_login_handler.google_login,
"microsoft": obj_login_handler.microsoft_login
}
......@@ -51,6 +51,39 @@ async def login_default(
status_code=status.HTTP_200_OK)
# Forgot Password API
@router.post(ApiEndPoints.asset_manager_forgot)
async def forgot_password(
validation_data: EmailValidation
):
try:
# forgot password
response = obj_login_handler.forgot_password_handler(validation_data.email)
return response
except Exception as e:
logger.exception(e)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.OP_FAILED).dict(),
status_code=status.HTTP_200_OK)
# Reset Password API
@router.get(ApiEndPoints.asset_manager_reset)
async def forgot_password(
token: str
):
try:
# forgot password
print(token)
except Exception as e:
logger.exception(e)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.OP_FAILED).dict(),
status_code=status.HTTP_200_OK)
# Create new users API
@router.post(ApiEndPoints.asset_manager_user_add)
async def user_register(
......@@ -60,12 +93,13 @@ async def user_register(
try:
response = AuthorizeAccess().admin_authorize(request)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
# mapper for login types
register_mapper = {
"normal": obj_user_handler.normal_register,
"general": obj_user_handler.normal_register,
"google": obj_user_handler.google_register,
"microsoft": obj_user_handler.microsoft_register
}
......@@ -96,9 +130,10 @@ async def user_register(
try:
response = AuthorizeAccess().admin_authorize(request)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
response = obj_user_handler.update_user_details(email, update_data)
return response
except Exception as e:
......@@ -118,9 +153,10 @@ async def user_register(
try:
response = AuthorizeAccess().admin_authorize(request)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
response = obj_user_handler.delete_user_details(email)
return response
except Exception as e:
......@@ -139,9 +175,10 @@ async def user_register(
try:
response = AuthorizeAccess().admin_authorize(request)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
response = obj_user_handler.fetch_user_details()
if not response:
return HTTPException(
......@@ -156,17 +193,18 @@ async def user_register(
status_code=status.HTTP_200_OK)
# download Button Dashboard header
@router.post(ApiEndPoints.asset_manager_dashboard_download_header)
# download Button Dashboard
@router.post(ApiEndPoints.asset_manager_dashboard_download)
async def dashboard_download(
request: MetaInfoSchema = Depends(auth)
):
try:
response = AuthorizeAccess().admin_authorize(request)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS)
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
response = obj_dashboard_handler.download_header()
if not response:
return HTTPException(
......@@ -181,18 +219,21 @@ async def dashboard_download(
status_code=status.HTTP_200_OK)
# download Button Dashboard
@router.post(ApiEndPoints.asset_manager_dashboard_download)
async def dashboard_download(
# API for users search filter
@router.post(ApiEndPoints.asset_manager_user_search)
async def user_search_filter(
payload_data: Request,
request: MetaInfoSchema = Depends(auth)
):
try:
response = AuthorizeAccess().admin_authorize(request)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS)
response = obj_dashboard_handler.download_details()
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
request_body = await payload_data.json()
response = obj_user_handler.user_filter_data(request_body)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="UTF-8" content="">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta name="x-apple-disable-message-reformatting" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="telephone=no" name="format-detection">
<title></title>
<!--[if (mso 16)]>
<style type="text/css">a{text-decoration:none}</style>
<![endif]-->
<!--[if gte mso 9]>
<style>sup{font-size:100%!important}</style><![endif]-->
<!--[if !mso]> ln-->
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,700,700i" rel="stylesheet">
<!--<![endif]-->
<style amp-custom type="">
@media only screen and (max-width:600px){.st-br{padding-left:10px;padding-right:10px}p,ul li,ol li,a{font-size:16px;line-height:150%}h1{font-size:30px;text-align:center;line-height:120%}h2{font-size:26px;text-align:center;line-height:120%}h3{font-size:20px;text-align:center;line-height:120%}h1 a{font-size:30px;text-align:center}h2 a{font-size:26px;text-align:center}h3 a{font-size:20px;text-align:center}.es-menu td a{font-size:14px}.es-header-body p,.es-header-body ul li,.es-header-body ol li,.es-header-body a{font-size:16px}.es-footer-body p,.es-footer-body ul li,.es-footer-body ol li,.es-footer-body a{font-size:14px}.es-infoblock p,.es-infoblock ul li,.es-infoblock ol li,.es-infoblock a{font-size:12px}*[class="gmail-fix"]{display:none}.es-m-txt-c,.es-m-txt-c h1,.es-m-txt-c h2,.es-m-txt-c h3{text-align:center}.es-m-txt-r,.es-m-txt-r h1,.es-m-txt-r h2,.es-m-txt-r h3{text-align:right}.es-m-txt-l,.es-m-txt-l h1,.es-m-txt-l h2,.es-m-txt-l h3{text-align:left}.es-m-txt-r amp-img{float:right}.es-m-txt-c amp-img{margin:0 auto}.es-m-txt-l amp-img{float:left}.es-button-border{display:block}a.es-button{font-size:16px;display:block;border-left-width:0;border-right-width:0}.es-btn-fw{border-width:10px 0;text-align:center}.es-adaptive table,.es-btn-fw,.es-btn-fw-brdr,.es-left,.es-right{width:100%}.es-content table,.es-header table,.es-footer table,.es-content,.es-footer,.es-header{width:100%;max-width:600px}.es-adapt-td{display:block;width:100%}.adapt-img{width:100%;height:auto}.es-m-p0{padding:0}.es-m-p0r{padding-right:0}.es-m-p0l{padding-left:0}.es-m-p0t{padding-top:0}.es-m-p0b{padding-bottom:0}.es-m-p20b{padding-bottom:20px}.es-mobile-hidden,.es-hidden{display:none}.es-desk-hidden{display:table-row;width:auto;overflow:visible;float:none;max-height:inherit;line-height:inherit}.es-desk-menu-hidden{display:table-cell}table.es-table-not-adapt,.esd-block-html table{width:auto}table.es-social{display:inline-block}table.es-social td{display:inline-block}}a[x-apple-data-detectors]{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}.es-desk-hidden{display:none;float:left;overflow:hidden;width:0;max-height:0;line-height:0}.es-button-border:hover{border-style:solid solid solid solid;background:#d6a700;border-color:#42d159 #42D159 #42d159 #42D159}.es-button-border:hover a.es-button{background:#d6a700;border-color:#d6a700}s{text-decoration:line-through}body{width:100%;font-family:roboto,"helvetica neue",helvetica,arial,sans-serif}table{border-collapse:collapse;border-spacing:0}table td,html,body,.es-wrapper{padding:0;Margin:0}.es-content,.es-header,.es-footer{table-layout:fixed;width:100%}p,hr{Margin:0}h1,h2,h3,h4,h5{Margin:0;line-height:120%;font-family:tahoma,verdana,segoe,sans-serif}.es-left{float:left}.es-right{float:right}.es-p5{padding:5px}.es-p5t{padding-top:5px}.es-p5b{padding-bottom:5px}.es-p5l{padding-left:5px}.es-p5r{padding-right:5px}.es-p10{padding:10px}.es-p10t{padding-top:10px}.es-p10b{padding-bottom:10px}.es-p10l{padding-left:10px}.es-p10r{padding-right:10px}.es-p15{padding:15px}.es-p15t{padding-top:15px}.es-p15b{padding-bottom:15px}.es-p15l{padding-left:15px}.es-p15r{padding-right:15px}.es-p20{padding:20px}.es-p20t{padding-top:20px}.es-p20b{padding-bottom:20px}.es-p20l{padding-left:20px}.es-p20r{padding-right:20px}.es-p25{padding:25px}.es-p25t{padding-top:25px}.es-p25b{padding-bottom:25px}.es-p25l{padding-left:25px}.es-p25r{padding-right:25px}.es-p30{padding:30px}.es-p30t{padding-top:30px}.es-p30b{padding-bottom:30px}.es-p30l{padding-left:30px}.es-p30r{padding-right:30px}.es-p35{padding:35px}.es-p35t{padding-top:35px}.es-p35b{padding-bottom:35px}.es-p35l{padding-left:35px}.es-p35r{padding-right:35px}.es-p40{padding:40px}.es-p40t{padding-top:40px}.es-p40b{padding-bottom:40px}.es-p40l{padding-left:40px}.es-p40r{padding-right:40px}.es-menu td{border:0}a{font-family:roboto,"helvetica neue",helvetica,arial,sans-serif;font-size:16px;text-decoration:none}h1{font-size:30px;font-style:normal;font-weight:bold;color:#212121}h1 a{font-size:30px}h2{font-size:24px;font-style:normal;font-weight:bold;color:#212121}h2 a{font-size:24px}h3{font-size:20px;font-style:normal;font-weight:normal;color:#212121}h3 a{font-size:20px}p,ul li,ol li{font-size:16px;font-family:roboto,"helvetica neue",helvetica,arial,sans-serif;line-height:150%}ul li,ol li{Margin-bottom:15px}.es-menu td a{text-decoration:none;display:block}.es-wrapper{width:100%;height:100%}.es-wrapper-color{background-color:#f6f6f6}.es-content-body{background-color:transparent}.es-content-body p,.es-content-body ul li,.es-content-body ol li{color:#131313}.es-content-body a{color:#2cb543}.es-header{background-color:transparent}.es-header-body{background-color:#fff}.es-header-body p,.es-header-body ul li,.es-header-body ol li{color:#333;font-size:14px}.es-header-body a{color:#1376c8;font-size:14px}.es-footer{background-color:#f6f6f6}.es-footer-body{background-color:transparent}.es-footer-body p,.es-footer-body ul li,.es-footer-body ol li{color:#131313;font-size:16px}.es-footer-body a{color:#000;font-size:16px}.es-infoblock,.es-infoblock p,.es-infoblock ul li,.es-infoblock ol li{line-height:120%;font-size:12px;color:#fff}.es-infoblock a{font-size:12px;color:#fff}.es-button-border{border-style:solid solid solid solid;border-color:#2cb543 #2CB543 #2cb543 #2CB543;background:#ffc80a;border-width:0;display:inline-block;border-radius:3px;width:auto}.es-p-default{padding-top:0;padding-right:0;padding-bottom:0;padding-left:0}.es-p-all-default{padding:0}
</style>
</head>
<body class="es-wrapper-color">
<div class="es-wrapper-color">
<!--[if gte mso 9]>
<v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
<v:fill type="tile" color="#f6f6f6">.</v:fill>
</v:background>
<![endif]-->
<table class="es-wrapper" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="esd-email-paddings st-br" valign="top">
<table cellpadding="0" cellspacing="0" class="es-header esd-header-popover" align="center">
<tbody>
<tr>
<td class="esd-stripe esd-checked" align="center">
<div>
<table bgcolor="transparent" class="es-header-body" align="center" cellpadding="0"
cellspacing="0" width="600" style="background-color:transparent">
<tbody>
<tr>
<td class="esd-structure es-p20t es-p20r es-p20l" align="left">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="560" class="esd-container-frame" align="center"
valign="top">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="center" class="esd-block-spacer"
height="65"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if gte mso 9]> </v:textbox> </v:rect> <![endif]-->
</td>
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" class="es-content" align="center">
<tbody>
<tr>
<td class="esd-stripe" align="center" bgcolor="transparent"
style="background-color:transparent">
<table bgcolor="transparent" class="es-content-body" align="center" cellpadding="0"
cellspacing="0" width="600" style="background-color:transparent">
<tbody>
<tr>
<td class="esd-structure es-p30t es-p15b es-p30r es-p30l" align="left"
style="border-radius:10px 10px 0 0;background-color:#fff" bgcolor="#ffffff">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="540" class="esd-container-frame" align="center" valign="top">
<table cellpadding="0" cellspacing="0" width="100%"
style="background-position:left bottom">
<tbody>
<tr>
<td align="center" class="esd-block-text">
<h1><img width = "200" src='https://cloud.ilens.io/assets/images/logo.png' alt="iLens Logo"></h1>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" class="esd-footer-popover es-footer" align="center">
<tbody>
<tr>
<td class="esd-stripe esd-checked" align="center">
<table bgcolor="#31cb4b" class="es-footer-body" align="center" cellpadding="0"
cellspacing="0" width="600">
<tbody>
<tr>
<td class="esd-structure es-p20t es-p20b es-p30r es-p30l" align="left"
style="background-position:left top;background-color:#fafafa" bgcolor="#fafafa">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="540" class="esd-container-frame" align="center" valign="top">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="left" class="esd-block-text es-m-txt-c">
<p style="line-height:150%">Greetings<strong>,
</strong><br><br>{{ message }}</p>
<br><br/>
<a href="{{ link }}"
class="download-link"
style="color: blue"
target="_blank">Click here
to download</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="esd-structure es-p20t es-p20b es-p30r es-p30l" align="left"
style="background-color:#fafafa" bgcolor="#fafafa">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="540" class="esd-container-frame" align="center" valign="top">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="esd-structure es-p30t es-p30b es-p30r es-p30l"
style="border-radius:0 0 10px 10px;background-color:#efefef" align="left"
bgcolor="#efefef">
<table cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td class="es-m-p0r esd-container-frame" width="540" align="center">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left" class="esd-block-text">
<p style="color:#010101; font-size:80%;">
Thanks &
Regards,<br>UnifyTwin
Team<br>
<br>This is an automatically generated email, do not reply.
<br>For any technical assistance
kindly contact support.<br>
<a style="color:#010101; font-size:90%;"
href="mailto:support@unifytwin.com">
Contact us at support@unifytwin.com
</a>&nbsp;
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="esd-structure" align="left" style="background-position:left top">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="600" class="esd-container-frame" align="center" valign="top">
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="center" class="esd-block-spacer"
height="40"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
......@@ -4,14 +4,6 @@ from scripts.logging.logger import logger
class RegexValidation:
@staticmethod
def first_name_validation(first_name):
try:
regex = re.fullmatch('([A-Za-z ]{1,100})', str(first_name))
return regex
except Exception as e:
logger.error(f'An Error While listing the home plans {str(e)}')
@staticmethod
def name_validation(name):
try:
......@@ -28,15 +20,6 @@ class RegexValidation:
except Exception as e:
logger.error(f'An Error While listing the home plans {str(e)}')
@staticmethod
def email_validation(email):
try:
regex = r'\b[A-Za-z0-9._%+-]+@([A-Za-z0-9.-]{5,20})+\.[A-Z|a-z]{3}\b'
if re.fullmatch(regex, email):
return regex
except Exception as e:
logger.error(f'An Error While listing the home plans {str(e)}')
@staticmethod
def password_validation(password):
try:
......
class ResponseData:
@staticmethod
def user_view():
header = {
"actions": [
{
"class": "fa-pencil",
"action": "edit",
"tooltip": "Edit"
},
{
"class": "fa-trash",
"action": "delete",
"tooltip": "Delete"
}
], "externalActions": [
{
"type": "button",
"action": "addnew",
"label": "Create User"
}
], "columnDefs": [
{
"headerName": "User Name",
"field": "userName",
"key": "userName"
},
{
"headerName": "Name",
"field": "name",
"key": "name"
},
{
"headerName": "Role",
"field": "role",
"key": "role"
}
],
}
return header
@staticmethod
def download_file_data():
data = {
"SCN101-Manual (Local Config with IoTSetupUI)":
"https://ilens.io/DownloadFiles/SCN_Device_Configuration_Page_Updates_4_7.pdf",
"SCN101 Firmware 4.7 Updates":
"https://ilens.io/DownloadFiles/SCN101Manual.pdf",
"IoTSetupUI":
"https://ilens.io/DownloadFiles/IoTsetupUI-V1.6.zip",
"CP2102 SCN Windows USB Driver":
"https://ilens.io/DownloadFiles/CP2102_Windows.zip",
"SCNFirmwareBurner":
"https://ilens.io/DownloadFiles/flash_download_tool_v3.8.5.zip",
"SCN101A Firmware - V2.7 (Board: 1.4, 1.6 and 4MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_Firmware_V2_7_B1_6.bin",
"SCN101A Firmware - V2.8 (Board: 1.4, 1.6 and 4MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_Firmware_V2_8_B1_6.bin",
"SCN101A4G (SCN Relay, 4G, SCN201 and SCN101L) Firmware - V4.5 (16MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_R_A4G_SCN201_Firmware_V4_5.bin",
"SCN101A4G (SCN Relay, 4G, SCN201 and SCN101L) Firmware - V4.6 (16MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_R_A4G_SCN201_Firmware_V4_6.bin",
"SCN101A4G (SCN Relay, 4G, SCN201 and SCN101L) Firmware - V4.7 (16MB Part.) ":
"https://ilens.io/DownloadFiles/SCN101_R_A4G_SCN201_Firmware_V4_7.bin",
"P10_LED_Driver_V2.1 (Board 1.1)":
"https://ilens.io/DownloadFiles/P10_LED_Driver_V2.1.bin",
"SCN-LED Reset Firmware (Board 1.1)":
"https://ilens.io/DownloadFiles/SCN-LED_Reset.bin",
"SCN Reset Firmware (Partition: 4MB)":
"https://ilens.io/DownloadFiles/SCN_Reset_4MB_Part.bin",
"SCN Reset Firmware (Partition: 16MB)":
"https://ilens.io/DownloadFiles/SCN_Reset_16MB_Part.bin"
}
return data
......@@ -6,7 +6,10 @@ obj_mongo_user = MongoUser()
class AuthorizeAccess:
@staticmethod
def admin_authorize(request):
user_data = obj_mongo_user.fetch_one_user_details(request.user_id)
if user_data["user_role"] != "super admin":
try:
user_data = obj_mongo_user.fetch_one_user_details(request.user_id)
if user_data["user_role"] != "super admin":
return False
return True
except TypeError:
return False
return True
......@@ -39,5 +39,5 @@ class EncryptDecryptPassword:
def password_encrypt(self, password):
decrypted_password = self.password_decrypt(password)
hashed_password = self.pwd_context.hash(decrypted_password)
hashed_password = self.pwd_context.hash(decrypted_password.split("\"")[1])
return hashed_password
......@@ -18,14 +18,14 @@ class UserDataValidations:
user_data.email) is not True:
return False, {"message": ErrorMessages.ERROR_INVALID_EMAIL, "data": user_data.email}
# checking for valid password
if method == 'normal':
if method == 'general':
if user_data.password == "" or user_data.password == "string":
return False, {"message": ErrorMessages.ERROR_INVALID_PASSWORD, "data": user_data.password}
# Validate phone number
if user_data.phone_number == "":
return False, {"message": ErrorMessages.ERROR_INVALID_PHONE_NUMBER,
"data": user_data.phone_number}
if user_data.user_role == "" and method == 'normal' and feature == 'register':
if user_data.user_role == "" and method == 'general' and feature == 'register':
return False, {"message": ErrorMessages.ERROR_INVALID_USER_ROLE,
"data": user_data.phone_number}
return True, None
......
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