From acd72ffa8ae242eb2a54c1ff3221dc79c54588da Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Mon, 24 Jun 2024 14:28:46 +0100 Subject: [PATCH] [+] TODO : firebase_manager.py Signed-off-by: Charles Le Maux --- firebase_manager.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 firebase_manager.py diff --git a/firebase_manager.py b/firebase_manager.py new file mode 100644 index 0000000..10bb4fa --- /dev/null +++ b/firebase_manager.py @@ -0,0 +1,30 @@ +import jwt +import firebase_admin +from firebase_admin import credentials, auth + +cred = credentials.Certificate('servii.json') +firebase_admin.initialize_app(cred) + + +''' +TODO +Write a function that launches upon app's startup, it does check in the firestore for any already running servers. +Fetches the PID's. +Stops all the current processes, +Tell the database they have now stopped running. +Also ensure the program can add an additional argument to avoid this checking for scalability. +''' + +def get_user_from_id(user_id): + return auth.get_user(user_id) + + +def verify_jwt_token(token): + try: + decoded_token = jwt.decode(token, options={"verify_signature": False}) + user_id = decoded_token.get('sub') + return True, user_id + except jwt.ExpiredSignatureError: + return False, None + except jwt.InvalidTokenError: + return False, None