mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50:31 +00:00
9ad1bdaff9
Now uses firebase complete tokens; it verifies the signature and integrity of the token, the origin of the project the token was issued for, the secret key, and finally the sub before verifying the account.
51 lines
2.8 KiB
Python
51 lines
2.8 KiB
Python
import os
|
|
import shutil
|
|
from typing import Callable, Union
|
|
|
|
from firebase_admin import auth
|
|
from jwt.api_jws import decode_complete
|
|
|
|
import firebase_manager
|
|
import server_mc_manager
|
|
from generic_executor import mc_manager
|
|
|
|
|
|
def ban_user(user_id: str):
|
|
try:
|
|
firebase_manager.auth.update_user(user_id, disabled=False)
|
|
print("Banned : " + user_id)
|
|
except Exception as e:
|
|
print("Error banning user " + user_id, "|", str(e), type(e).__name__)
|
|
|
|
|
|
def organize_minecraft_files(file_list: list[str], target_directory: str):
|
|
os.makedirs(target_directory, exist_ok=True)
|
|
|
|
for file_name in file_list:
|
|
if file_name.endswith('.jar'):
|
|
version = file_name.split('-')[1]
|
|
version_folder = os.path.join(target_directory, version)
|
|
|
|
os.makedirs(version_folder, exist_ok=True)
|
|
|
|
source_path = os.path.join(target_directory, file_name)
|
|
destination_path = os.path.join(version_folder, 'server.jar')
|
|
|
|
shutil.move(source_path, destination_path)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
#ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53")
|
|
#file_manager.log_action("gqZN3eCHF3V2er3Py3rlgk8u2t83", "test", "DeleteServer")
|
|
#firebase_manager.set_servers_not_running()
|
|
#print(firebase_manager.get_server_field("secret :)", "AMITIE" ,"version"))
|
|
'''
|
|
organize_minecraft_files(
|
|
listdir("/home/hapso/Desktop/Personal/servii-backend/servers/paper"),
|
|
"/home/hapso/Desktop/Personal/servii-backend/servers/paper")
|
|
'''
|
|
token: str = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImUwM2E2ODg3YWU3ZjNkMTAyNzNjNjRiMDU3ZTY1MzE1MWUyOTBiNzIiLCJ0eXAiOiJKV1QifQ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