Compare commits
No commits in common. "2034b4211ad79a5f8677d712fa9b5d7e18af8c80" and "cd2f84b84e81ef867f5c83bc405003a308f3600e" have entirely different histories.
2034b4211a
...
cd2f84b84e
@ -86,8 +86,6 @@ def validate_account() -> Tuple[Response, int]:
|
||||
data = request.get_json()
|
||||
username = data.get("username")
|
||||
password = data.get("password")
|
||||
expiry_date = data.get("expiry_date")
|
||||
stream = data.get("stream")
|
||||
|
||||
if not all([username, password]):
|
||||
return jsonify({"message": "Missing required fields"}), 400
|
||||
@ -97,20 +95,6 @@ def validate_account() -> Tuple[Response, int]:
|
||||
result = single_account_check(account_data, stream_urls)
|
||||
|
||||
if result:
|
||||
if expiry_date and stream and int(result["data"]["user_info"]["exp_date"]) != expiry_date:
|
||||
from ktvmanager.lib.database import update_expiry_date
|
||||
update_expiry_date(
|
||||
username, stream, result["data"]["user_info"]["exp_date"]
|
||||
)
|
||||
return jsonify({"message": "Account is valid and updated", "data": result}), 200
|
||||
|
||||
if result.get("data", {}).get("user_info", {}).get("max_connections") and data.get("max_connections") and result["data"]["user_info"]["max_connections"] != data.get("max_connections"):
|
||||
from ktvmanager.lib.database import update_max_connections
|
||||
update_max_connections(
|
||||
username, stream, result["data"]["user_info"]["max_connections"]
|
||||
)
|
||||
return jsonify({"message": "Account is valid and updated", "data": result}), 200
|
||||
|
||||
return jsonify({"message": "Account is valid", "data": result}), 200
|
||||
return jsonify({"message": "Account is valid"}), 200
|
||||
else:
|
||||
return jsonify({"message": "Account is invalid"}), 401
|
@ -127,7 +127,7 @@ def add_account(user_id: int) -> Response:
|
||||
data = request.form
|
||||
res = single_account_check(data, get_latest_urls_from_dns())
|
||||
encrypted_password = encrypt_password(data["password"])
|
||||
query = "INSERT INTO userAccounts (username, stream, streamURL, expiaryDate, password, userID, maxConnections) VALUES (%s, %s, %s, %s, %s, %s, %s)"
|
||||
query = "INSERT INTO userAccounts (username, stream, streamURL, expiaryDate, password, userID) VALUES (%s, %s, %s, %s, %s, %s)"
|
||||
params = (
|
||||
data["username"],
|
||||
data["stream"],
|
||||
@ -135,38 +135,11 @@ def add_account(user_id: int) -> Response:
|
||||
res["data"]["user_info"]["exp_date"],
|
||||
encrypted_password,
|
||||
user_id,
|
||||
res["data"]["user_info"]["max_connections"],
|
||||
)
|
||||
result = _execute_query(query, params)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
def update_expiry_date(username: str, stream: str, expiry_date: str) -> None:
|
||||
"""Updates the expiry date of an account.
|
||||
|
||||
Args:
|
||||
username: The username of the account.
|
||||
stream: The stream of the account.
|
||||
expiry_date: The new expiry date.
|
||||
"""
|
||||
query = "UPDATE userAccounts SET expiaryDate = %s WHERE username = %s AND stream = %s"
|
||||
params = (expiry_date, username, stream)
|
||||
_execute_query(query, params)
|
||||
|
||||
|
||||
def update_max_connections(username: str, stream: str, max_connections: int) -> None:
|
||||
"""Updates the max connections of an account.
|
||||
|
||||
Args:
|
||||
username: The username of the account.
|
||||
stream: The stream of the account.
|
||||
max_connections: The new max connections value.
|
||||
"""
|
||||
query = "UPDATE userAccounts SET maxConnections = %s WHERE username = %s AND stream = %s"
|
||||
params = (max_connections, username, stream)
|
||||
_execute_query(query, params)
|
||||
|
||||
|
||||
def delete_account(user_id: int) -> Response:
|
||||
"""Deletes an account for a user.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user