continue developing account page, start transaction pages

This commit is contained in:
Lucas Mathews
2024-05-29 15:38:25 +02:00
parent 01bbffa561
commit b70ba6ae2e
11 changed files with 238 additions and 32 deletions

View File

@@ -173,7 +173,7 @@ def get_client(client_id:str):
return format_response(False, "Client not found."), 404
@login_required
def update_client(client_id: str, otp_code: int, **kwargs):
def update_client(client_id:str, otp_code:int, **kwargs):
"""Updates a client in the database. If the client is not found, returns an error message."""
current_client_id, is_admin = get_current_client()
if not verify_otp(current_client_id, otp_code):
@@ -260,9 +260,11 @@ def add_account(client_id:str, description:str, account_type:str, **kwargs):
return format_response(True, f"New account has been added: account_id: {account_id}"), 200
@login_required
def update_account(account_id:str, **kwargs):
def update_account(account_id:str, otp_code:str, **kwargs):
"""Updates an account in the database. If the account is not found, returns an error message."""
current_client_id, is_admin = get_current_client()
if not verify_otp(current_client_id, otp_code):
return format_response(False, "Invalid OTP."), 400
account_owner = session.query(Account).filter_by(account_id=account_id).one_or_none().client_id
if not is_admin and account_owner != current_client_id:
return format_response(False, "You can only view your own client information."), 403