add mgmt command to get mesh login url

This commit is contained in:
wh1te909 2024-03-27 17:28:32 +00:00
parent 1a325a66b4
commit 35c8b4f535
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
from django.core.management.base import BaseCommand
from meshctrl.utils import get_login_token
from core.utils import get_core_settings
class Command(BaseCommand):
help = "generate a url to login to mesh as the superuser"
def handle(self, *args, **kwargs):
core = get_core_settings()
token = get_login_token(key=core.mesh_token, user=f"user//{core.mesh_username}")
token_param = f"login={token}&"
control = f"{core.mesh_site}/?{token_param}"
self.stdout.write(self.style.SUCCESS(control))