stvtermux 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
STVTermux/__init__.py
ADDED
STVTermux/cli.py
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
from .core import Auth
|
2
|
+
|
3
|
+
def main():
|
4
|
+
auth = Auth()
|
5
|
+
|
6
|
+
print("===== 🌐 STVTermux Login System 🌐 =====")
|
7
|
+
while True:
|
8
|
+
choice = input("👉 Bạn muốn (1) Đăng ký hay (2) Đăng nhập? ")
|
9
|
+
if choice == "1":
|
10
|
+
u = input("Nhập username: ")
|
11
|
+
p = input("Nhập password: ")
|
12
|
+
auth.register(u, p)
|
13
|
+
elif choice == "2":
|
14
|
+
u = input("Nhập username: ")
|
15
|
+
p = input("Nhập password: ")
|
16
|
+
auth.login(u, p)
|
17
|
+
else:
|
18
|
+
print("Chọn 1 hoặc 2!")
|
STVTermux/core.py
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
import requests
|
2
|
+
import json
|
3
|
+
|
4
|
+
FIREBASE_URL = "https://sever-login-ae5cc-default-rtdb.firebaseio.com/player.json"
|
5
|
+
|
6
|
+
class Auth:
|
7
|
+
def __init__(self, firebase_url=FIREBASE_URL):
|
8
|
+
self.firebase_url = firebase_url
|
9
|
+
|
10
|
+
def register(self, username: str, password: str) -> bool:
|
11
|
+
"""Đăng ký tài khoản mới"""
|
12
|
+
res = requests.get(self.firebase_url)
|
13
|
+
if res.status_code != 200:
|
14
|
+
print("❌ Lỗi kết nối server!")
|
15
|
+
return False
|
16
|
+
|
17
|
+
data = res.json() or {}
|
18
|
+
for _, user in data.items():
|
19
|
+
if user.get("username") == username:
|
20
|
+
print("❌ Username đã tồn tại!")
|
21
|
+
return False
|
22
|
+
|
23
|
+
new_user = {"username": username, "password": password}
|
24
|
+
post_res = requests.post(self.firebase_url, data=json.dumps(new_user))
|
25
|
+
if post_res.status_code == 200:
|
26
|
+
print("✅ Đăng ký thành công!")
|
27
|
+
return True
|
28
|
+
print("❌ Đăng ký thất bại!")
|
29
|
+
return False
|
30
|
+
|
31
|
+
def login(self, username: str, password: str) -> bool:
|
32
|
+
"""Đăng nhập tài khoản"""
|
33
|
+
res = requests.get(self.firebase_url)
|
34
|
+
if res.status_code != 200:
|
35
|
+
print("❌ Lỗi kết nối server!")
|
36
|
+
return False
|
37
|
+
|
38
|
+
data = res.json() or {}
|
39
|
+
for _, user in data.items():
|
40
|
+
if user.get("username") == username and user.get("password") == password:
|
41
|
+
print("✅ Đăng nhập thành công!")
|
42
|
+
return True
|
43
|
+
|
44
|
+
print("❌ Sai username hoặc password!")
|
45
|
+
return False
|
@@ -0,0 +1,8 @@
|
|
1
|
+
STVTermux/__init__.py,sha256=jO2dYCn26G5OUkVmDxV1o8emaODqrjFWFg_bUzv0chM,45
|
2
|
+
STVTermux/cli.py,sha256=VJNI75nECsVXAKaO7hkpqS7YtSRgmEODHc0AlXvoH8Q,569
|
3
|
+
STVTermux/core.py,sha256=Rke-UPrT-wDA_YC4K9hynQfW6g1KPB5V5Lqh2_NxPMk,1625
|
4
|
+
stvtermux-1.0.1.dist-info/METADATA,sha256=dA6wWiEezWBZUCwb9Rlk6U3oQwEWMPgT863hL_AZQcU,203
|
5
|
+
stvtermux-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
stvtermux-1.0.1.dist-info/entry_points.txt,sha256=7b0IuLqKSWL2VMJxcTdMLZXBaPfYT1atz6wwBTqco9Q,43
|
7
|
+
stvtermux-1.0.1.dist-info/top_level.txt,sha256=FiA4bsFGDzFNuRMuwRG2Ewmwm4SSMwCJwCpyZotvYy0,10
|
8
|
+
stvtermux-1.0.1.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
STVTermux
|