From 6102de37dea8c6d0a24988f81a3040f4ea2be448 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Wed, 15 Nov 2023 20:19:55 +0530 Subject: [PATCH] dev: check email validity --- .../license/management/commands/register_instance.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apiserver/plane/license/management/commands/register_instance.py b/apiserver/plane/license/management/commands/register_instance.py index 52f8213d9..855a3a035 100644 --- a/apiserver/plane/license/management/commands/register_instance.py +++ b/apiserver/plane/license/management/commands/register_instance.py @@ -7,6 +7,8 @@ import uuid # Django imports from django.core.management.base import BaseCommand, CommandError from django.utils import timezone +from django.core.exceptions import ValidationError +from django.core.validators import validate_email # Module imports from plane.db.models import User @@ -27,6 +29,12 @@ class Command(BaseCommand): data = json.load(file) admin_email = os.environ.get("ADMIN_EMAIL") + + try: + validate_email(admin_email) + except ValidationError: + CommandError(f"{admin_email} is not a valid ADMIN_EMAIL") + # Raise an exception if the admin email is not provided if not admin_email: raise CommandError("ADMIN_EMAIL is required")