Skip to content

Commit

Permalink
Properly create new superuser
Browse files Browse the repository at this point in the history
  • Loading branch information
zediious committed Dec 22, 2023
1 parent 5df70f1 commit ad8a4de
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions raptorWeb/authprofiles/management/commands/createSuper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ class Command(BaseCommand):

def handle(self, *args, **options):
if RaptorUser.objects.count() == 0:
for user in ADMINS:
admin_info = UserProfileInfo.objects.create()
admin_info.save()
username = user[0].replace(' ', '')
email = user[1]
password = 'admin'
admin = RaptorUser.objects.create_superuser(email=email, username=username, password=password)
admin.user_slug = slugify(username)
admin.user_profile_info = admin_info
admin.is_discord_user = False
admin.is_active = True
admin.is_admin = True
admin.is_staff = True
admin.is_superuser = True
admin.save()
self.stdout.write(f"[INFO] Base superuser created with username: {admin.username}. Change the credentials!", ending='')
default_admin = ADMINS[0]
admin_info = UserProfileInfo.objects.create()
admin_info.save()
username = default_admin[0].replace(' ', '')
email = default_admin[1]
password = 'admin'
admin = RaptorUser.objects.create_superuser(email=email, username=username, password=password)
admin.user_slug = slugify(username)
admin.user_profile_info = admin_info
admin.is_discord_user = False
admin.is_active = True
admin.is_admin = True
admin.is_staff = True
admin.is_superuser = True
admin.save()
self.stdout.write(f"[INFO] Base superuser created with username: {admin.username}. Change the credentials!", ending='')

else:
self.stdout.write("[INFO] Base superuser can only be initialized if no Accounts exist", ending='')

0 comments on commit ad8a4de

Please sign in to comment.