mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50:31 +00:00
[+] Simple ban function
Signed-off-by: Charles Le Maux <charles.le-maux@epitech.eu>
This commit is contained in:
parent
8dfe9bbde9
commit
f9534c6aa2
@ -100,7 +100,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
function sendRequest(endpoint, payload) {
|
||||
return fetch(`http://127.0.0.1:3000/${endpoint}`, {
|
||||
return fetch(`https://www.servii.fr/api/${endpoint}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
42
unit_test.py
42
unit_test.py
@ -1,42 +1,14 @@
|
||||
import file_manager
|
||||
import firebase_manager
|
||||
|
||||
db = firebase_manager.firestore_database
|
||||
users = firebase_manager.auth.list_users().users
|
||||
|
||||
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 create_properties_collection(uid, name):
|
||||
"""Create properties collection for a specific server of a user."""
|
||||
properties = {
|
||||
"difficulty": "easy",
|
||||
"gamemode": "survival",
|
||||
"force-gamemode": False,
|
||||
"hardcore": False,
|
||||
"generate-structures": True,
|
||||
"motd": "A Minecraft Server",
|
||||
"pvp": True,
|
||||
"online-mode": True,
|
||||
"max-players": 20,
|
||||
"enable-command-block": False
|
||||
}
|
||||
|
||||
doc_ref = db.document(f'users/{uid}/servers/{name}')
|
||||
#doc_ref.set(properties)
|
||||
doc_ref.delete()
|
||||
|
||||
|
||||
def get_servers(uid):
|
||||
servers_ref = db.collection(f'users/{uid}/servers').stream()
|
||||
servers_names = [doc.id for doc in servers_ref]
|
||||
return servers_names
|
||||
|
||||
|
||||
if __name__ == 'voituredecourse':
|
||||
for user in users:
|
||||
user_id = user.uid
|
||||
servers = get_servers(user_id)
|
||||
for server_id in servers:
|
||||
create_properties_collection(user_id, server_id)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(file_manager.kebab_to_camel_case("enable-command-block"))
|
||||
ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53")
|
||||
|
Loading…
Reference in New Issue
Block a user