mirror of
https://github.com/Such-Software/xmrcheckout.git
synced 2026-10-17 05:51:34 +02:00
Add OPEN_REGISTRATION gate, signup request form, favicon
This commit is contained in:
@@ -31,6 +31,7 @@ DONATION_EXPIRY_MINUTES = int(os.getenv("DONATION_EXPIRY_MINUTES", "30"))
|
||||
DONATION_ACTIVE_INVOICE_LIMIT = int(os.getenv("DONATION_ACTIVE_INVOICE_LIMIT", "25"))
|
||||
RATE_PROVIDER = os.getenv("RATE_PROVIDER", "kraken")
|
||||
DONATIONS_ENABLED = _get_bool_env("DONATIONS_ENABLED", False)
|
||||
OPEN_REGISTRATION = _get_bool_env("OPEN_REGISTRATION", True)
|
||||
|
||||
MONERO_WALLET_RPC_URLS = [
|
||||
url.strip()
|
||||
|
||||
@@ -22,6 +22,7 @@ from .config import (
|
||||
FOUNDER_PAYMENT_ADDRESS,
|
||||
FOUNDER_VIEW_KEY,
|
||||
INVOICE_DEFAULT_EXPIRY_HOURS,
|
||||
OPEN_REGISTRATION,
|
||||
QR_STORAGE_DIR,
|
||||
)
|
||||
from .db import get_db
|
||||
@@ -724,6 +725,11 @@ def login_user(payload: LoginRequest, db: Session = Depends(get_db)):
|
||||
_validate_payment_address_and_view_key(payment_address, view_key)
|
||||
user = db.query(User).filter(User.payment_address == payment_address).first()
|
||||
if user is None:
|
||||
if not OPEN_REGISTRATION:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="registration_closed",
|
||||
)
|
||||
api_key = generate_api_key()
|
||||
webhook_secret = generate_webhook_secret()
|
||||
user = User(
|
||||
@@ -770,6 +776,11 @@ def validate_login(payload: LoginRequest) -> Response:
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
@router.get("/api/core/auth/registration-status")
|
||||
def registration_status():
|
||||
return {"open": OPEN_REGISTRATION}
|
||||
|
||||
|
||||
@router.post(
|
||||
"/api/core/api-credentials/reset",
|
||||
response_model=ApiCredentialsResetResponse,
|
||||
|
||||
Reference in New Issue
Block a user