mirror of
https://github.com/lnbits/lnbits.git
synced 2025-05-30 17:49:55 +02:00
feat: add fiat providers
This commit is contained in:
parent
ac9800c381
commit
b0c286d58b
@ -190,6 +190,7 @@ async def get_user_from_account(
|
||||
wallets=wallets,
|
||||
admin=account.is_admin,
|
||||
super_user=account.is_super_user,
|
||||
fiat_providers=account.fiat_providers,
|
||||
has_password=account.password_hash is not None,
|
||||
)
|
||||
|
||||
|
@ -104,11 +104,13 @@ class Account(BaseModel):
|
||||
|
||||
is_super_user: bool = Field(default=False, no_database=True)
|
||||
is_admin: bool = Field(default=False, no_database=True)
|
||||
fiat_providers: list[str] = Field(default=[], no_database=True)
|
||||
|
||||
def __init__(self, **data):
|
||||
super().__init__(**data)
|
||||
self.is_super_user = settings.is_super_user(self.id)
|
||||
self.is_admin = settings.is_admin_user(self.id)
|
||||
self.fiat_providers = settings.get_fiat_providers_for_user(self.id)
|
||||
|
||||
def hash_password(self, password: str) -> str:
|
||||
"""sets and returns the hashed password"""
|
||||
@ -171,6 +173,7 @@ class User(BaseModel):
|
||||
wallets: list[Wallet] = []
|
||||
admin: bool = False
|
||||
super_user: bool = False
|
||||
fiat_providers: list[str] = []
|
||||
has_password: bool = False
|
||||
extra: UserExtra = UserExtra()
|
||||
|
||||
|
@ -564,6 +564,7 @@ class StrikeFundingSource(LNbitsSettings):
|
||||
|
||||
|
||||
class StripeFundingSource(LNbitsSettings):
|
||||
stripe_enabled: bool = Field(default=False)
|
||||
stripe_endpoint: str = Field(default="https://api.stripe.com")
|
||||
stripe_secret_key: str | None = Field(default=None)
|
||||
# empty list means all users are allowed to receive payments via Stripe
|
||||
@ -604,7 +605,17 @@ class FundingSourcesSettings(
|
||||
|
||||
|
||||
class FiatFundingSourcesSettings(StripeFundingSource):
|
||||
pass
|
||||
|
||||
def get_fiat_providers_for_user(self, user_id: str) -> list[str]:
|
||||
"""
|
||||
Returns a list of fiat payment methods allowed for the user.
|
||||
"""
|
||||
allowed_providers = []
|
||||
if not self.stripe_allowed_users or user_id in self.stripe_allowed_users:
|
||||
allowed_providers.append("stripe")
|
||||
|
||||
# Add other fiat providers here as needed
|
||||
return allowed_providers
|
||||
|
||||
|
||||
class WebPushSettings(LNbitsSettings):
|
||||
|
@ -178,7 +178,7 @@ async def test_login_alan_username_password_ok(
|
||||
assert user.email == "alan@lnbits.com", "Email check."
|
||||
assert not user.pubkey, "No pubkey."
|
||||
assert not user.admin, "Not admin."
|
||||
assert not user.super_user, "Not superuser."
|
||||
assert not user.super_user, "Not superuser." # todo: add test for fiat providers
|
||||
assert user.has_password, "Password configured."
|
||||
assert (
|
||||
len(user.wallets) == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user