validation for the ip address and record type
This commit is contained in:
parent
afa7fce1c4
commit
be0f853346
1 changed files with 7 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ from http import HTTPStatus
|
||||||
from lnbits.core.crud import get_user, get_wallet
|
from lnbits.core.crud import get_user, get_wallet
|
||||||
from lnbits.core.services import create_invoice, check_invoice_status
|
from lnbits.core.services import create_invoice, check_invoice_status
|
||||||
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
||||||
|
from .util import validIPAddress
|
||||||
|
|
||||||
from . import subdomains_ext
|
from . import subdomains_ext
|
||||||
from .crud import (
|
from .crud import (
|
||||||
|
|
@ -110,8 +111,13 @@ async def api_subdomains():
|
||||||
)
|
)
|
||||||
async def api_subdomain_make_subdomain(domain_id):
|
async def api_subdomain_make_subdomain(domain_id):
|
||||||
domain = await get_domain(domain_id)
|
domain = await get_domain(domain_id)
|
||||||
|
|
||||||
if not domain:
|
if not domain:
|
||||||
return jsonify({"message": "LNsubdomain does not exist."}), HTTPStatus.NOT_FOUND
|
return jsonify({"message": "LNsubdomain does not exist."}), HTTPStatus.NOT_FOUND
|
||||||
|
if not validIPAddress(g.data["ip"]):
|
||||||
|
return jsonify({"message": g.data["ip"] + " Not a valid IP address"}), HTTPStatus.BAD_REQUEST
|
||||||
|
if g.data["record_type"] not in domain.allowed_record_types:
|
||||||
|
return jsonify({"message": g.data["record_type"] + "Not a valid record"}), HTTPStatus.BAD_REQUEST
|
||||||
|
|
||||||
subdomain = g.data["subdomain"]
|
subdomain = g.data["subdomain"]
|
||||||
duration = g.data["duration"]
|
duration = g.data["duration"]
|
||||||
|
|
@ -164,3 +170,4 @@ async def api_subdomain_delete(subdomain_id):
|
||||||
await delete_subdomain(subdomain_id)
|
await delete_subdomain(subdomain_id)
|
||||||
|
|
||||||
return "", HTTPStatus.NO_CONTENT
|
return "", HTTPStatus.NO_CONTENT
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue