Compare commits
No commits in common. "master" and "1.3.8" have entirely different histories.
@ -148,14 +148,9 @@ def add_account(user_id: int) -> Response:
|
||||
user_id: The ID of the user.
|
||||
|
||||
Returns:
|
||||
A Flask JSON response confirming the account was added or an error message.
|
||||
A Flask JSON response confirming the account was added.
|
||||
"""
|
||||
data = request.form
|
||||
|
||||
# Check if account already exists
|
||||
if account_exists(user_id, data["username"], data["stream"]):
|
||||
return jsonify({"error": "Account already exists for this user"}), 409
|
||||
|
||||
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)"
|
||||
@ -172,23 +167,6 @@ def add_account(user_id: int) -> Response:
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
def account_exists(user_id: int, username: str, stream: str) -> bool:
|
||||
"""Check if an account with the same username and stream already exists for the user.
|
||||
|
||||
Args:
|
||||
user_id: The ID of the user.
|
||||
username: The username of the account.
|
||||
stream: The stream of the account.
|
||||
|
||||
Returns:
|
||||
True if the account exists, False otherwise.
|
||||
"""
|
||||
query = "SELECT COUNT(*) as count FROM userAccounts WHERE userID = %s AND username = %s AND stream = %s"
|
||||
params = (user_id, username, stream)
|
||||
result = _execute_query(query, params)
|
||||
return result[0]["count"] > 0
|
||||
|
||||
|
||||
def update_expiry_date(username: str, stream: str, expiry_date: str) -> None:
|
||||
"""Updates the expiry date of an account.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user