update expiry
This commit is contained in:
parent
cd2f84b84e
commit
842ac5aae2
@ -86,6 +86,8 @@ 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
|
||||
@ -95,6 +97,11 @@ def validate_account() -> Tuple[Response, int]:
|
||||
result = single_account_check(account_data, stream_urls)
|
||||
|
||||
if result:
|
||||
return jsonify({"message": "Account is valid"}), 200
|
||||
if expiry_date and stream and 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", "data": result}), 200
|
||||
else:
|
||||
return jsonify({"message": "Account is invalid"}), 401
|
@ -140,6 +140,19 @@ def add_account(user_id: int) -> Response:
|
||||
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 delete_account(user_id: int) -> Response:
|
||||
"""Deletes an account for a user.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user