rename to get_user_from_account

This commit is contained in:
dni ⚡
2024-10-17 10:43:04 +02:00
parent deee7d80be
commit aa98e38dfc
7 changed files with 17 additions and 19 deletions
+3 -5
View File
@@ -166,16 +166,14 @@ async def get_account_by_username_or_email(
)
async def get_user_by_id(
user_id: str, conn: Optional[Connection] = None
) -> Optional[User]:
async def get_user(user_id: str, conn: Optional[Connection] = None) -> Optional[User]:
account = await get_account(user_id, conn)
if not account:
return None
return await get_user(account, conn)
return await get_user_from_account(account, conn)
async def get_user(
async def get_user_from_account(
account: Account, conn: Optional[Connection] = None
) -> Optional[User]:
extensions = await get_user_active_extensions_ids(account.id, conn)
+2 -2
View File
@@ -57,7 +57,7 @@ from .crud import (
get_standalone_payment,
get_super_settings,
get_total_balance,
get_user,
get_user_from_account,
get_wallet,
get_wallet_payment,
is_internal_status_success,
@@ -843,7 +843,7 @@ async def create_user_account(
user_ext = UserExtension(user=account.id, extension=ext_id, active=True)
await update_user_extension(user_ext)
user = await get_user(account)
user = await get_user_from_account(account)
assert user, "Cannot find user for account."
return user
+2 -2
View File
@@ -15,7 +15,7 @@ from fastapi import (
from fastapi.exceptions import HTTPException
from fastapi.responses import StreamingResponse
from lnbits.core.crud import get_user_by_id
from lnbits.core.crud import get_user
from lnbits.core.models import (
BaseWallet,
ConversionData,
@@ -61,7 +61,7 @@ async def health_check(wallet: WalletTypeInfo = Depends(require_invoice_key)) ->
"up_time": int(time() - settings.server_startup_time),
}
user = await get_user_by_id(wallet.wallet.user)
user = await get_user(wallet.wallet.user)
if not user:
return stat
+4 -4
View File
@@ -29,7 +29,7 @@ from ..crud import (
get_account_by_pubkey,
get_account_by_username,
get_account_by_username_or_email,
get_user,
get_user_from_account,
update_account,
)
from ..models import (
@@ -199,7 +199,7 @@ async def update_pubkey(
account.pubkey = normalize_public_key(data.pubkey)
await update_account(account)
return await get_user(account)
return await get_user_from_account(account)
@auth_router.put("/password")
@@ -228,7 +228,7 @@ async def update_password(
account.username = data.username
account.hash_password(data.password)
await update_account(account)
_user = await get_user(account)
_user = await get_user_from_account(account)
if not _user:
raise HTTPException(HTTPStatus.NOT_FOUND, "User not found.")
return _user
@@ -306,7 +306,7 @@ async def update(
account.extra = data.extra
await update_account(account)
return await get_user(account)
return await get_user_from_account(account)
@auth_router.put("/first_install")
+2 -2
View File
@@ -25,7 +25,7 @@ from ..crud import (
create_wallet,
get_db_versions,
get_installed_extensions,
get_user_by_id,
get_user,
get_wallet,
)
@@ -232,7 +232,7 @@ async def service_worker(request: Request):
@generic_router.get("/manifest/{usr}.webmanifest")
async def manifest(request: Request, usr: str):
host = urlparse(str(request.url)).netloc
user = await get_user_by_id(usr)
user = await get_user(usr)
if not user:
raise HTTPException(status_code=HTTPStatus.NOT_FOUND)
return {
+2 -2
View File
@@ -14,8 +14,8 @@ from lnbits.core.crud import (
get_account,
get_account_by_email,
get_account_by_username,
get_user,
get_user_active_extensions_ids,
get_user_from_account,
get_wallet_for_key,
)
from lnbits.core.models import (
@@ -151,7 +151,7 @@ async def check_user_exists(
if not settings.is_user_allowed(account.id):
raise HTTPException(HTTPStatus.UNAUTHORIZED, "User not allowed.")
user = await get_user(account)
user = await get_user_from_account(account)
if not user:
raise HTTPException(HTTPStatus.UNAUTHORIZED, "User not found.")
await _check_user_extension_access(user.id, r["path"])
+2 -2
View File
@@ -23,7 +23,7 @@ from lnbits.core.crud import (
get_account,
get_account_by_username,
get_payment,
get_user,
get_user_from_account,
update_payment,
)
from lnbits.core.models import Account, CreateInvoice, PaymentState, User
@@ -171,7 +171,7 @@ def from_super_user(from_user: User, settings: Settings):
async def superuser(settings: Settings):
account = await get_account(settings.super_user)
assert account, "Superuser not found"
user = await get_user(account)
user = await get_user_from_account(account)
yield user