Commit 3fdc6a3e authored by arun.uday's avatar arun.uday

AssetManager-V1.0- Not reviewed

> Added google login functionality, completed the API for forgot password, reset password and change password functionality.
> Changed the normal_login handler name
parent 8f0c4a48
......@@ -21,4 +21,6 @@ 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
RESET_ENDPOINT=http://localhost:8671/asset_manager_api/v1/login/reset?token
CLIENT_ID=1060631831358-a21djaa3hm165a8976fnmo1lerujs5p6.apps.googleusercontent.com
\ No newline at end of file
uvicorn==0.21.1
python-dotenv~=1.0.0
pydantic~=1.10.6
pydantic==1.10.7
fastapi==0.95.0
passlib~=1.7.4
pymongo~=4.3.3
......@@ -9,4 +9,7 @@ email-validator~=1.3.1
pycryptodomex~=3.17
PyJWT~=2.6.0
validate_email~=1.3
redis~=4.5.2
\ No newline at end of file
redis==4.5.4
google~=3.0.0
google-auth~=2.17.1
requests~=2.28.2
\ No newline at end of file
......@@ -46,6 +46,7 @@ class _Secrets(BaseSettings):
TOKEN_EXPIRE_TIME = 5
leeway_in_minutes: int = 10
KEY_ENCRYPTION: str
CLIENT_ID: str
issuer: str = "iotManager"
SECRET_KEY: str
ALGORITHM = "HS256"
......
class ApiEndPoints:
# Main root
root = "/asset_manager_api"
# version
version = "/v1"
......@@ -32,6 +35,7 @@ class ApiEndPoints:
asset_manager_user_delete: str = asset_manager_user_management + delete
asset_manager_user_search: str = asset_manager_user_management + search
asset_manager_user_logout: str = asset_manager_user_management + logout
asset_manager_user_reset: str = asset_manager_user_management + reset
# dashboard-management
asset_manager_dashboard: str = "/dashboard"
......
......@@ -4,11 +4,17 @@ from datetime import timedelta, datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from jwt.exceptions import ExpiredSignatureError
from google.oauth2 import id_token
from google.auth.transport import requests
from google.auth.exceptions import InvalidValue
from fastapi import status
from fastapi.responses import JSONResponse
from fastapi.responses import JSONResponse, RedirectResponse
from scripts.config import Services, Secrets
from scripts.core.handlers.normal_login import NormalLogin
from scripts.core.handlers.process_login_data import NormalLogin
from scripts.database.mongo.mongo_db import MongoUser
from scripts.errors import ErrorMessages
from scripts.logging.logger import logger
......@@ -64,9 +70,46 @@ class LoginHandlers:
response.set_cookie(key="login-token", value=responses, expires=exp)
return response
# v2
def google_login(self, request):
pass
def google_login(self, user_data, request):
user_data_remove_none = {key: value for key, value in user_data if key != 'login_type' and value is not None}
req = requests.Request()
try:
id_info = id_token.verify_oauth2_token(
user_data_remove_none["id_token"], req, Secrets.CLIENT_ID)
except InvalidValue:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_TOKEN_EXPIRED).dict(),
status_code=status.HTTP_200_OK)
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
# if the response is false then an error message is send back
if response is not None:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=message).dict(),
status_code=status.HTTP_200_OK)
message.update({"name": id_info["name"], "pic_url": id_info["picture"]})
responses = self.obj_login_handler.update_pic(obj_mongo_user, id_info)
if responses is None:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_IN_UPDATING).dict(),
status_code=status.HTTP_200_OK)
# generating the access tokens
responses, exp = self.obj_login_handler.generate_cookie_tokens(message, request)
# token generation unsuccessful
if responses is None:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_TOKEN_GENERATION).dict(),
status_code=status.HTTP_200_OK)
# sending successful response to UI
response = JSONResponse(
content=DefaultResponse(status="success", message="Logged In Successfully",
data=message).dict(),
status_code=status.HTTP_200_OK, headers={"Content-Type": "application/json"})
response.set_cookie(key="login-token", value=responses, expires=exp)
return response
# v2
def microsoft_login(self, request):
......@@ -90,7 +133,7 @@ class LoginHandlers:
mail = MIMEMultipart()
mail['From'] = Services.EMAIL_SENDER
mail['To'] = email
mail['Subject'] = "Link TO Reset Password"
mail['Subject'] = "Link To Reset Password"
to_encode = {"email": email}
expire = datetime.utcnow() + timedelta(minutes=Secrets.TOKEN_EXPIRE_TIME)
to_encode.update({"exp": expire})
......@@ -117,3 +160,61 @@ class LoginHandlers:
status_code=status.HTTP_200_OK)
except Exception as e:
logger.exception(e)
@staticmethod
def validate_jwt(request):
try:
jwt_token = request.query_params['token']
jwt_token_encoded = jwt_token.encode('utf-8')
# Verify and decode the JWT token
try:
decoded_token = jwt.decode(jwt_token_encoded)
db_user_data = obj_mongo_user.fetch_one_user_details({"email": decoded_token['email']})
# if the user is not available
if not db_user_data:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_USER_ID_DOESNT_EXIST).dict(),
status_code=status.HTTP_200_OK)
jwt_token_new = jwt.encode({"email": decoded_token['email']})
return RedirectResponse('http://192.168.2.102/iLens_UI/#/l/login?user_id=' + jwt_token_new)
except ExpiredSignatureError:
return RedirectResponse(
'http://192.168.2.102/iLens_UI/#/l/login?error=' + "true")
except Exception as e:
logger.exception(e)
@staticmethod
def reset_user_password(reset_data):
try:
user_id_token = reset_data.user_id
user_id = user_id_token.encode('utf-8')
# Verify and decode the JWT token
try:
decoded_token = jwt.decode(user_id)
db_user_data = obj_mongo_user.fetch_one_user_details({"email": decoded_token['email']})
# if the user is not available
if not db_user_data:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_USER_ID_DOESNT_EXIST).dict(),
status_code=status.HTTP_200_OK)
response = EncryptDecryptPassword().password_encrypt(reset_data.password)
if not response:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_AUTH_FAILED).dict(),
status_code=status.HTTP_200_OK)
response = obj_mongo_user.update_user({"email": decoded_token['email']}, {"password": response})
if not response:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_IN_UPDATING).dict(),
status_code=status.HTTP_200_OK)
return JSONResponse(
content=DefaultSuccessResponse(status="success", message="Reset Successful").dict(),
status_code=status.HTTP_200_OK)
except ExpiredSignatureError:
return "Password Reset Token Expired"
except Exception as e:
logger.exception(e)
......@@ -43,9 +43,17 @@ class NormalLogin:
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
return False, ErrorMessages.ERROR_ACCESS_DENIED
try:
response = {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
"email": email,
"user_role": self.db_user_data["user_role"]}
except KeyError:
response = {"user_id": self.db_user_data["user_id"],
"email": email,
"user_role": self.db_user_data["user_role"]}
# if the user exist
return None, {"message": True}
return None, response
except Exception as e:
logger.exception(e)
......@@ -61,12 +69,17 @@ class NormalLogin:
if not self.pwd_context.verify(password, self.db_user_data["password"]):
return False, ErrorMessages.ERROR_PASSWORD_MISMATCH
# if the password is correct
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
"email": user_data.email,
"user_role": self.db_user_data["user_role"]}
return None, message
except Exception as e:
logger.exception(e)
@staticmethod
def update_pic(obj_mongo_user, info_data):
if not obj_mongo_user.update_user({"email": info_data["email"]},
{"name": info_data["name"], "pic_url": info_data["picture"]}):
return None
return True
# cookie and token creation
@staticmethod
def generate_cookie_tokens(user_data, request):
......
......@@ -221,6 +221,33 @@ class UserManagement:
except Exception as e:
logger.exception(e)
# user change password
@staticmethod
def reset_password(reset_data):
db_user_data = obj_mongo_user.fetch_one_user_details({"user_id": reset_data.user_id})
# if the user is not available
if db_user_data is None:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_USER_ID_DOESNT_EXIST).dict(),
status_code=status.HTTP_404_NOT_FOUND)
response = EncryptDecryptPassword().password_encrypt(reset_data.password)
if not response:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_AUTH_FAILED).dict(),
status_code=status.HTTP_200_OK)
response = obj_mongo_user.update_user({"user_id": reset_data.user_id}, {"password": response})
if not response:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_IN_UPDATING).dict(),
status_code=status.HTTP_200_OK)
return JSONResponse(
content=DefaultSuccessResponse(status="success", message="Updated Successfully").dict(),
status_code=status.HTTP_200_OK)
# user logout
@staticmethod
def logout_user(user_id, request):
......
......@@ -6,7 +6,7 @@ class ErrorMessages:
ERROR_INVALID_LOGIN = "Your are not authorized to view this website."
ERROR_UNAUTHORIZED_USER_LOGIN = "Account is not available"
ERROR_UNAUTHORIZED_ACCESS = "Your are not authorized to view this page"
ERROR_LOGIN_TYPE_INVALID = "Invalid Login Method"
ERROR_ACCESS_DENIED = "Access Denied!"
ERROR_USER_NOT_REGISTERED = "Account is not registered in the portal."
ERROR_PASSWORD_MISMATCH = "Please enter the correct password"
ERROR_TOKEN_GENERATION = "Unsuccessful token generation"
......@@ -16,6 +16,7 @@ class ErrorMessages:
ERROR_IN_UPDATING = "Error in Updating"
ERROR_INVALID_REQUEST = "Invalid Request"
ERROR_USER_SESSION = "Not The Users Session"
ERROR_TOKEN_EXPIRED = "Google Token Expired"
# Data Validation
ERROR_INVALID_PASSWORD = "Invalid Password"
......
......@@ -3973,3 +3973,611 @@ AttributeError: 'NoneType' object has no attribute 'split'
2023-03-30 15:16:20 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-30 15:26:35 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-03-30 16:40:56 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 11:01:29 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 11:02:05 - ERROR - [MainThread:login_default(): 47] - google_login() takes 2 positional arguments but 3 were given
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 40, in login_default
return login_mapper[user_data.login_type](user_data, request)
TypeError: google_login() takes 2 positional arguments but 3 were given
2023-04-03 11:12:46 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 11:22:04 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 11:22:06 - ERROR - [MainThread:<module>(): 41] - The requests library is not installed, please install the requests package to use the requests transport.
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 24, in import_from_string
raise exc from None
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 6, in <module>
from scripts.core.handlers.login_handler import LoginHandlers
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 7, in <module>
from google.oauth2 import id_token
File "E:\Git\meta-services\venv\lib\site-packages\google\oauth2\id_token.py", line 67, in <module>
import google.auth.transport.requests
File "E:\Git\meta-services\venv\lib\site-packages\google\auth\transport\requests.py", line 30, in <module>
six.raise_from(
File "<string>", line 3, in raise_from
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
2023-04-03 11:22:12 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 11:22:12 - ERROR - [MainThread:<module>(): 41] - The requests library is not installed, please install the requests package to use the requests transport.
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 24, in import_from_string
raise exc from None
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 6, in <module>
from scripts.core.handlers.login_handler import LoginHandlers
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 7, in <module>
from google.oauth2 import id_token
File "E:\Git\meta-services\venv\lib\site-packages\google\oauth2\id_token.py", line 67, in <module>
import google.auth.transport.requests
File "E:\Git\meta-services\venv\lib\site-packages\google\auth\transport\requests.py", line 30, in <module>
six.raise_from(
File "<string>", line 3, in raise_from
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
2023-04-03 11:24:07 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:13:06 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:13:12 - ERROR - [MainThread:login_default(): 46] - Token expired, 1680502844 < 1680504192
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 73, in google_login
id_info = id_token.verify_oauth2_token(
File "E:\Git\meta-services\venv\lib\site-packages\google\oauth2\id_token.py", line 163, in verify_oauth2_token
idinfo = verify_token(
File "E:\Git\meta-services\venv\lib\site-packages\google\oauth2\id_token.py", line 135, in verify_token
return jwt.decode(
File "E:\Git\meta-services\venv\lib\site-packages\google\auth\jwt.py", line 309, in decode
_verify_iat_and_exp(payload, clock_skew_in_seconds)
File "E:\Git\meta-services\venv\lib\site-packages\google\auth\jwt.py", line 229, in _verify_iat_and_exp
raise exceptions.InvalidValue("Token expired, {} < {}".format(latest, now))
google.auth.exceptions.InvalidValue: Token expired, 1680502844 < 1680504192
2023-04-03 12:17:44 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:23:45 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:23:58 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:24:26 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:25:38 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:40:31 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:40:43 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:40:56 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:42:59 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:48:52 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:49:10 - ERROR - [MainThread:db_data_validation(): 52] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 48, in db_data_validation
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 12:49:10 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 12:50:10 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 12:50:12 - ERROR - [MainThread:db_data_validation(): 53] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 49, in db_data_validation
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 12:50:12 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 12:50:36 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 13:04:10 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 13:04:24 - ERROR - [MainThread:db_data_validation(): 53] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 49, in db_data_validation
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 13:04:24 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 14:18:58 - ERROR - [MainThread:db_data_validation(): 53] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 49, in db_data_validation
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 14:18:58 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 14:19:01 - ERROR - [MainThread:db_data_validation(): 53] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 49, in db_data_validation
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 14:19:01 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 14:19:51 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 14:20:02 - ERROR - [MainThread:db_data_validation(): 52] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 48, in db_data_validation
return None, {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 14:20:02 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 14:21:12 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 14:21:17 - ERROR - [MainThread:db_data_validation(): 54] - 'name'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 47, in db_data_validation
response = {"user_id": self.db_user_data["user_id"], "name": self.db_user_data["name"],
KeyError: 'name'
2023-04-03 14:21:17 - ERROR - [MainThread:login_default(): 46] - cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 82, in google_login
response, message = self.obj_login_handler.db_data_validation(user_data.login_type, id_info["email"])
TypeError: cannot unpack non-iterable NoneType object
2023-04-03 14:23:22 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 14:23:26 - ERROR - [MainThread:login_default(): 46] - 'pic_url'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 90, in google_login
responses = self.obj_login_handler.update_pic(obj_mongo_user, id_info)
File "E:\Git\meta-services\scripts\core\handlers\process_login_data.py", line 80, in update_pic
{"name": info_data["name"], "pic_url": info_data["pic_url"]}):
KeyError: 'pic_url'
2023-04-03 14:24:10 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 14:26:55 - ERROR - [MainThread:login_default(): 46] - 'id_token'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 76, in google_login
user_data_remove_none["id_token"], req, Secrets.CLIENT_ID)
KeyError: 'id_token'
2023-04-03 14:38:52 - ERROR - [MainThread:login_default(): 46] - 'id_token'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 39, in login_default
return login_mapper[user_data.login_type](user_data, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 76, in google_login
user_data_remove_none["id_token"], req, Secrets.CLIENT_ID)
KeyError: 'id_token'
2023-04-03 15:05:33 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 15:05:33 - ERROR - [MainThread:<module>(): 41] - expected an indented block (iot_manager_services.py, line 77)
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 77
except Exception as e:
^
IndentationError: expected an indented block
2023-04-03 15:05:40 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 15:05:40 - ERROR - [MainThread:<module>(): 41] - expected an indented block (iot_manager_services.py, line 77)
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 77
except Exception as e:
^
IndentationError: expected an indented block
2023-04-03 15:06:07 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 15:13:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 15:29:36 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 15:31:55 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 15:32:22 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:23:56 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:29:36 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:37:18 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:37:19 - ERROR - [MainThread:<module>(): 41] - unexpected unindent (iot_manager_services.py, line 94)
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 94
except Exception as e:
IndentationError: unexpected unindent
2023-04-03 16:37:45 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:37:55 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:39:04 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:39:09 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Invalid token type. Token must be a <class 'bytes'>
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 191, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 247, in _load
raise DecodeError(f"Invalid token type. Token must be a {bytes}")
jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
2023-04-03 16:39:09 - ERROR - [MainThread:forgot_password(): 96] - Invalid token type. Token must be a <class 'bytes'>
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 84, in forgot_password
decoded_token = jwt.decode(jwt_token)
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 191, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 247, in _load
raise DecodeError(f"Invalid token type. Token must be a {bytes}")
jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
2023-04-03 16:39:56 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:43:44 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 16:43:50 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Invalid token type. Token must be a <class 'bytes'>
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 191, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 247, in _load
raise DecodeError(f"Invalid token type. Token must be a {bytes}")
jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
2023-04-03 16:43:50 - ERROR - [MainThread:forgot_password(): 96] - Invalid token type. Token must be a <class 'bytes'>
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 84, in forgot_password
decoded_token = jwt.decode(jwt_token)
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 191, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 247, in _load
raise DecodeError(f"Invalid token type. Token must be a {bytes}")
jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
2023-04-03 17:37:50 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Invalid token type. Token must be a <class 'bytes'>
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 191, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 247, in _load
raise DecodeError(f"Invalid token type. Token must be a {bytes}")
jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
2023-04-03 17:37:50 - ERROR - [MainThread:forgot_password(): 96] - Invalid token type. Token must be a <class 'bytes'>
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 84, in forgot_password
decoded_token = jwt.decode(jwt_token)
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 191, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jws.py", line 247, in _load
raise DecodeError(f"Invalid token type. Token must be a {bytes}")
jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
2023-04-03 17:39:28 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 17:39:31 - ERROR - [MainThread:forgot_password(): 96] - 'NoneType' object has no attribute 'encode'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 82, in forgot_password
jwt_token = jwt_token.encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'
2023-04-03 17:39:53 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 17:40:02 - ERROR - [MainThread:forgot_password(): 97] - 'NoneType' object has no attribute 'encode'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 83, in forgot_password
jwt_token = jwt_token.encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'
2023-04-03 17:41:27 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 17:41:31 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 17:41:31 - ERROR - [MainThread:forgot_password(): 97] - Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 85, in forgot_password
decoded_token = jwt.decode(jwt_token)
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 17:57:36 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 17:57:43 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 17:57:57 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 17:58:03 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 17:58:29 - ERROR - [MainThread:forgot_password(): 84] - 'APIRouter' object has no attribute 'redirect'
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\services\v1\iot_manager_services.py", line 81, in forgot_password
response = obj_login_handler.validate_jwt(router, request)
File "E:\Git\meta-services\scripts\core\handlers\login_handler.py", line 178, in validate_jwt
return router.redirect('http://192.168.2.102/iLens_UI/#/l/login')
AttributeError: 'APIRouter' object has no attribute 'redirect'
2023-04-03 17:59:43 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:10:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:10:24 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 18:11:19 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:11:22 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 18:12:14 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:12:23 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 18:13:18 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:28:43 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:41:23 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 18:42:13 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:42:20 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 18:43:02 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:43:08 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
2023-04-03 18:43:22 - ERROR - [MainThread:decode(): 26] - Exception while encoding JWT: Signature has expired
Traceback (most recent call last):
File "E:\Git\meta-services\scripts\utils\security\jwt_util.py", line 24, in decode
return jwt.decode(token, self.key, algorithms=self.alg)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 136, in decode_complete
self._validate_claims(
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 199, in _validate_claims
self._validate_exp(payload, now, leeway)
File "E:\Git\meta-services\venv\lib\site-packages\jwt\api_jwt.py", line 237, in _validate_exp
raise ExpiredSignatureError("Signature has expired")
jwt.exceptions.ExpiredSignatureError: Signature has expired
2023-04-03 19:04:54 - INFO - [MainThread:<module>(): 37] - App Starting at 0.0.0.0:8671
......@@ -6,8 +6,9 @@ from pydantic import BaseModel
# model for login request
class LoginRequest(BaseModel):
login_type: str
email: str
password: str
email: Optional[str] = None
password: Optional[str] = None
id_token: Optional[str] = None
class RegistrationData(BaseModel):
......@@ -36,6 +37,11 @@ class UsersFilter(BaseModel):
user_role: Optional[str] = None
class ResetPassword(BaseModel):
user_id: str
password: str
class UserIDValidation(BaseModel):
user_id: str
......
from fastapi import APIRouter
from scripts.constants.api import ApiEndPoints
from scripts.services import v1
router = APIRouter()
router = APIRouter(prefix=ApiEndPoints.root)
# routing to the V1 router
router.include_router(v1.router)
......@@ -3,6 +3,6 @@ from scripts.constants.api import ApiEndPoints
from scripts.services.v1 import iot_manager_services
# creating the api router with version as the prefix
router = APIRouter()
router = APIRouter(prefix=ApiEndPoints.version)
# routing to the service api
router.include_router(iot_manager_services.router)
......@@ -8,12 +8,12 @@ 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, UserActions, EmailValidation, UserIDValidation
from scripts.schemas.project_schema import LoginRequest, UserActions, EmailValidation, UserIDValidation, ResetPassword
from scripts.utils.security.authorize_access import AuthorizeAccess
from scripts.utils.security.decorators import MetaInfoSchema, auth
# creating the login api
router = APIRouter(prefix=ApiEndPoints.version)
router = APIRouter()
# initializing the handler
obj_login_handler = LoginHandlers()
obj_user_handler = UserManagement()
......@@ -67,14 +67,32 @@ async def forgot_password(
status_code=status.HTTP_200_OK)
# Reset Password API
# Reset Password API for sending email
@router.get(ApiEndPoints.asset_manager_reset)
async def forgot_password(
token: str
async def reset_password(
request: Request
):
try:
# forgot password
print(token)
# Get the JWT token from the query parameters
response = obj_login_handler.validate_jwt(request)
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.post(ApiEndPoints.asset_manager_reset)
async def reset_password(
reset_data: ResetPassword
):
try:
# Get the JWT token from the query parameters
response = obj_login_handler.reset_user_password(reset_data)
return response
except Exception as e:
logger.exception(e)
return JSONResponse(
......@@ -154,7 +172,7 @@ async def user_register(
# View users API
@router.post(ApiEndPoints.asset_manager_user_view)
async def user_register(
async def user_register_view(
request: MetaInfoSchema = Depends(auth)
):
try:
......@@ -179,10 +197,38 @@ async def user_register(
status_code=status.HTTP_200_OK)
# API for reset password
@router.post(ApiEndPoints.asset_manager_user_reset)
async def user_reset_password(
reset_data: ResetPassword,
request: MetaInfoSchema = Depends(auth)
):
try:
# authorize the user
response = AuthorizeAccess().login_authorize(reset_data, request)
if not response:
return JSONResponse(
content=DefaultFailureResponse(status="failed",
message=ErrorMessages.ERROR_UNAUTHORIZED_ACCESS).dict(),
status_code=status.HTTP_200_OK)
response = obj_user_handler.reset_password(reset_data)
if not response:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ErrorMessages.ERROR_IN_FETCHING)
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)
# download Button Dashboard
@router.post(ApiEndPoints.asset_manager_dashboard_download)
async def dashboard_download(
request: MetaInfoSchema = Depends(auth)
):
try:
# getting the data for the download dashboard
......
......@@ -37,5 +37,5 @@ def create_token(
login_db.set(uid, new_token)
login_db.expire(uid, timedelta(minutes=age))
# Add updated time to mongo db
mongo_user.update_user({"email": user_id}, {"updated_at": current_time})
mongo_user.update_user({"user_id": user_id}, {"updated_at": current_time})
return uid, exp
......@@ -15,3 +15,9 @@ class AuthorizeAccess:
return True
except TypeError:
return False
@staticmethod
def login_authorize(reset_data, request):
if reset_data.user_id != request.user_id:
return False
return True
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