Add warning when hostname starts with http (fixes #68)

This commit is contained in:
R. Miles McCain 2020-08-11 21:39:08 +00:00
parent e4deab2072
commit 2d42674e1a
No known key found for this signature in database
GPG Key ID: F1053629E2905557

View File

@ -20,6 +20,12 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
site = Site.objects.get(pk=settings.SITE_ID) site = Site.objects.get(pk=settings.SITE_ID)
site.domain = options.get("hostname") site.domain = options.get("hostname")
if options.get("hostname").lower().startswith("http"):
self.stdout.write(
self.style.WARNING(
f"Warning: the hostname '{options.get('hostname')}' starts with `http`. You almost certainly don't want this. The hostname is supposed to be the raw domain name of your Shynet instance, without `http://` or `https://`. For example, if your Shynet instance will eventually be hosted at `https://analytics.example.com`, the hostname should be `analytics.example.com`."
)
)
site.save() site.save()
self.stdout.write( self.stdout.write(
self.style.SUCCESS( self.style.SUCCESS(